forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShardDataset.cs
More file actions
28 lines (25 loc) · 877 Bytes
/
ShardDataset.cs
File metadata and controls
28 lines (25 loc) · 877 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
using static Tensorflow.Binding;
namespace Tensorflow
{
/// <summary>
/// A `Dataset` for sharding its input.
/// </summary>
public class ShardDataset : UnaryUnchangedStructureDataset
{
Tensor _num_shards;
Tensor _index;
public ShardDataset(IDatasetV2 input_dataset,
int num_shards,
int index) : base(input_dataset)
{
_num_shards = tf.convert_to_tensor(num_shards, dtype: TF_DataType.TF_INT64, name: "num_shards");
_index = tf.convert_to_tensor(index, dtype: TF_DataType.TF_INT64, name: "index");
variant_tensor = ops.shard_dataset
(input_dataset.variant_tensor,
num_shards: _num_shards,
index: _index,
input_dataset.output_types,
input_dataset.output_shapes);
}
}
}