| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a3cf7ae commit b821d82
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,6 @@ Related merged [commits](https://github.com/SciSharp/TensorFlow.NET/commit/854a5 | |||
| 27 | 27 | On Windows, the tar command does not support extracting archives with symlinks. So when `dotnet pack` runs on Windows it will only package the Windows binaries. | |
| 28 | 28 | ||
| 29 | 29 | 1. Run `dotnet pack SciSharp.TensorFlow.Redist.nupkgproj` under `src/SciSharp.TensorFlow.Redist` directory in Linux. | |
| 30 | - 2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.1.15.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json` | ||
| 30 | + 2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.2.3.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json` | ||
| 31 | 31 | ||
| 32 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,7 +95,7 @@ public override string ToString() | |||
| 95 | 95 | ||
| 96 | 96 | public IEnumerator<(Tensor, Tensor)> GetEnumerator() | |
| 97 | 97 | { | |
| 98 | - var ownedIterator = new OwnedIterator(this); | ||
| 98 | + using var ownedIterator = new OwnedIterator(this); | ||
| 99 | 99 | ||
| 100 | 100 | Tensor[] results = null; | |
| 101 | 101 | while (true) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ namespace Tensorflow | |||
| 8 | 8 | /// <summary> | |
| 9 | 9 | /// An iterator producing tf.Tensor objects from a tf.data.Dataset. | |
| 10 | 10 | /// </summary> | |
| 11 | - public class OwnedIterator : IteratorBase | ||
| 11 | + public class OwnedIterator : IteratorBase, IDisposable | ||
| 12 | 12 | { | |
| 13 | 13 | IDatasetV2 _dataset; | |
| 14 | 14 | TensorSpec[] _element_spec; | |
@@ -45,5 +45,10 @@ public Tensor[] next() | |||
| 45 | 45 | throw new StopIteration(ex.Message); | |
| 46 | 46 | } | |
| 47 | 47 | } | |
| 48 | + | ||
| 49 | + public void Dispose() | ||
| 50 | + { | ||
| 51 | + _resource_deleter.Dispose(); | ||
| 52 | + } | ||
| 48 | 53 | } | |
| 49 | 54 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ public class KerasApi | |||
| 17 | 17 | public Initializers initializers { get; } = new Initializers(); | |
| 18 | 18 | public LayersApi layers { get; } = new LayersApi(); | |
| 19 | 19 | public Activations activations { get; } = new Activations(); | |
| 20 | - | ||
| 20 | + public Preprocessing preprocessing { get; } = new Preprocessing(); | ||
| 21 | 21 | public BackendImpl backend { get; } = new BackendImpl(); | |
| 22 | 22 | ||
| 23 | 23 | public Sequential Sequential(List<Layer> layers = null, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.Preprocessings | ||
| 6 | + { | ||
| 7 | + public partial class DatasetUtils | ||
| 8 | + { | ||
| 9 | + | ||
| 10 | + } | ||
| 11 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + using System; | ||
| 2 | + using System.Collections.Generic; | ||
| 3 | + using System.Text; | ||
| 4 | + | ||
| 5 | + namespace Tensorflow.Keras.Preprocessings | ||
| 6 | + { | ||
| 7 | + public partial class DatasetUtils | ||
| 8 | + { | ||
| 9 | + /// <summary> | ||
| 10 | + /// Make list of all files in the subdirs of `directory`, with their labels. | ||
| 11 | + /// </summary> | ||
| 12 | + /// <param name="directory"></param> | ||
| 13 | + /// <param name="labels"></param> | ||
| 14 | + /// <param name="formats"></param> | ||
| 15 | + /// <param name="class_names"></param> | ||
| 16 | + /// <param name="shuffle"></param> | ||
| 17 | + /// <param name="seed"></param> | ||
| 18 | + /// <param name="follow_links"></param> | ||
| 19 | + /// <returns> | ||
| 20 | + /// file_paths, labels, class_names | ||
| 21 | + /// </returns> | ||
| 22 | + public (string[], int[], string[]) index_directory(string directory, | ||
| 23 | + string labels, | ||
| 24 | + string[] formats, | ||
| 25 | + string class_names = null, | ||
| 26 | + bool shuffle = true, | ||
| 27 | + int? seed = null, | ||
| 28 | + bool follow_links = false) | ||
| 29 | + { | ||
| 30 | + throw new NotImplementedException(""); | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + using Tensorflow.Keras.Preprocessings; | ||
| 2 | + | ||
| 3 | + namespace Tensorflow.Keras | ||
| 4 | + { | ||
| 5 | + public partial class Preprocessing | ||
| 6 | + { | ||
| 7 | + public Sequence sequence => new Sequence(); | ||
| 8 | + public DatasetUtils dataset_utils => new DatasetUtils(); | ||
| 9 | + } | ||
| 10 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,57 @@ | |||
| 1 | + using System; | ||
| 2 | + using static Tensorflow.Binding; | ||
| 3 | + | ||
| 4 | + namespace Tensorflow.Keras | ||
| 5 | + { | ||
| 6 | + public partial class Preprocessing | ||
| 7 | + { | ||
| 8 | + public static string[] WHITELIST_FORMATS = new[] { ".bmp", ".gif", ".jpeg", ".jpg", ".png" }; | ||
| 9 | + | ||
| 10 | + /// <summary> | ||
| 11 | + /// Generates a `tf.data.Dataset` from image files in a directory. | ||
| 12 | + /// https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image_dataset_from_directory | ||
| 13 | + /// </summary> | ||
| 14 | + /// <param name="directory">Directory where the data is located.</param> | ||
| 15 | + /// <param name="labels"></param> | ||
| 16 | + /// <param name="label_mode"></param> | ||
| 17 | + /// <param name="class_names"></param> | ||
| 18 | + /// <param name="color_mode"></param> | ||
| 19 | + /// <param name="batch_size"></param> | ||
| 20 | + /// <param name="image_size"></param> | ||
| 21 | + /// <param name="shuffle"></param> | ||
| 22 | + /// <param name="seed"></param> | ||
| 23 | + /// <param name="validation_split"></param> | ||
| 24 | + /// <param name="subset"></param> | ||
| 25 | + /// <param name="interpolation"></param> | ||
| 26 | + /// <param name="follow_links"></param> | ||
| 27 | + /// <returns></returns> | ||
| 28 | + public Tensor image_dataset_from_directory(string directory, | ||
| 29 | + string labels = "inferred", | ||
| 30 | + string label_mode = "int", | ||
| 31 | + string class_names = null, | ||
| 32 | + string color_mode = "rgb", | ||
| 33 | + int batch_size = 32, | ||
| 34 | + TensorShape image_size = null, | ||
| 35 | + bool shuffle = true, | ||
| 36 | + int? seed = null, | ||
| 37 | + float validation_split = 0.2f, | ||
| 38 | + string subset = null, | ||
| 39 | + string interpolation = "bilinear", | ||
| 40 | + bool follow_links = false) | ||
| 41 | + { | ||
| 42 | + int num_channels = 0; | ||
| 43 | + if (color_mode == "rgb") | ||
| 44 | + num_channels = 3; | ||
| 45 | + // C:/Users/haipi/.keras/datasets/flower_photos | ||
| 46 | + var (image_paths, label_list, class_name_list) = tf.keras.preprocessing.dataset_utils.index_directory(directory, | ||
| 47 | + labels, | ||
| 48 | + WHITELIST_FORMATS, | ||
| 49 | + class_names: class_names, | ||
| 50 | + shuffle: shuffle, | ||
| 51 | + seed: seed, | ||
| 52 | + follow_links: follow_links); | ||
| 53 | + | ||
| 54 | + throw new NotImplementedException(""); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,7 +37,7 @@ PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU | |||
| 37 | 37 | ||
| 38 | 38 | ### Download prebuild binary manually | |
| 39 | 39 | ||
| 40 | - We can't found official prebuild binaries for each platform since tensorflow 2.0. If you know where we can download, please PR here. | ||
| 40 | + Tensorflow packages are built nightly and uploaded to GCS for all supported platforms. They are uploaded to the [libtensorflow-nightly](https://www.tensorflow.org/install/lang_c) GCS bucket and are indexed by operating system and date built. | ||
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | 43 | ### Build from source for Windows | |
| Back | FazBrowse Home | New Git URL |
0 commit comments