You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

DataSet.cs 852 B

6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930
  1. using NumSharp.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using Tensorflow;
  6. namespace TensorFlowNET.Examples.Utility
  7. {
  8. public class DataSet
  9. {
  10. private int _num_examples;
  11. private int _epochs_completed;
  12. private int _index_in_epoch;
  13. private NDArray _images;
  14. private NDArray _labels;
  15. public DataSet(NDArray images, NDArray labels, TF_DataType dtype, bool reshape)
  16. {
  17. _num_examples = images.shape[0];
  18. images = images.reshape(images.shape[0], images.shape[1] * images.shape[2]);
  19. images.astype(dtype.as_numpy_datatype());
  20. images = np.multiply(images, 1.0f / 255.0f);
  21. _images = images;
  22. _labels = labels;
  23. _epochs_completed = 0;
  24. _index_in_epoch = 0;
  25. }
  26. }
  27. }

tensorflow框架的.NET版本,提供了丰富的特性和API,可以借此很方便地在.NET平台下搭建深度学习训练与推理流程。