forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTensorDataset.cs
More file actions
29 lines (25 loc) · 828 Bytes
/
TensorDataset.cs
File metadata and controls
29 lines (25 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using Tensorflow.NumPy;
using System.Linq;
using static Tensorflow.Binding;
namespace Tensorflow
{
/// <summary>
/// A `Dataset` with a single element.
/// </summary>
public class TensorDataset : DatasetSource
{
public TensorDataset(Tensors elements)
{
_tensors = elements;
structure = _tensors.Select(x => x.ToTensorSpec()).ToArray();
variant_tensor = ops.tensor_dataset(_tensors, output_shapes);
}
public TensorDataset(NDArray element)
{
_tensors = new[] { tf.convert_to_tensor(element) };
var batched_spec = _tensors.Select(x => x.ToTensorSpec()).ToArray();
structure = batched_spec.ToArray();
variant_tensor = ops.tensor_dataset(_tensors, output_shapes);
}
}
}