|
| 1 | +using System; |
| 2 | +using System.Collections; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Linq; |
| 5 | +using System.Text; |
| 6 | +using Tensorflow.Framework.Models; |
| 7 | + |
| 8 | +namespace Tensorflow |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Abstract class representing a dataset with no inputs. |
| 12 | + /// </summary> |
| 13 | + public class DatasetV2 : IDatasetV2 |
| 14 | + { |
| 15 | + protected dataset_ops ops = new dataset_ops(); |
| 16 | + public Tensor variant_tensor { get; set; } |
| 17 | + |
| 18 | + public TensorSpec[] _structure { get; set; } |
| 19 | + |
| 20 | + public TensorShape[] output_shapes => _structure.Select(x => x.shape).ToArray(); |
| 21 | + |
| 22 | + public TF_DataType[] output_types => _structure.Select(x => x.dtype).ToArray(); |
| 23 | + |
| 24 | + public TensorSpec[] element_spec => _structure; |
| 25 | + |
| 26 | + public IDatasetV2 take(int count = -1) |
| 27 | + => new TakeDataset(this, count: count); |
| 28 | + |
| 29 | + public IDatasetV2 batch(int batch_size, bool drop_remainder = false) |
| 30 | + => new BatchDataset(this, batch_size, drop_remainder: drop_remainder); |
| 31 | + |
| 32 | + public IDatasetV2 prefetch(int buffer_size = -1, int? slack_period = null) |
| 33 | + => new PrefetchDataset(this, buffer_size: buffer_size, slack_period: slack_period); |
| 34 | + |
| 35 | + public IDatasetV2 repeat(int count = -1) |
| 36 | + => new RepeatDataset(this, count: count); |
| 37 | + |
| 38 | + public IDatasetV2 shuffle(int buffer_size, int? seed = null, bool reshuffle_each_iteration = true) |
| 39 | + => new ShuffleDataset(this, buffer_size, seed: seed, reshuffle_each_iteration: reshuffle_each_iteration); |
| 40 | + |
| 41 | + public override string ToString() |
| 42 | + => $"{GetType().Name} shapes: ({_structure[0].shape}, {_structure[1].shape}), types: (tf.{_structure[0].dtype.as_numpy_name()}, tf.{_structure[1].dtype.as_numpy_name()})"; |
| 43 | + |
| 44 | + public IEnumerator<(Tensor, Tensor)> GetEnumerator() |
| 45 | + { |
| 46 | + throw new NotImplementedException(); |
| 47 | + } |
| 48 | + |
| 49 | + IEnumerator IEnumerable.GetEnumerator() |
| 50 | + { |
| 51 | + return this.GetEnumerator(); |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments