@@ -27,6 +27,6 @@ Related merged [commits](https://github.com/SciSharp/TensorFlow.NET/commit/854a5 | |||||
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. | 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. | ||||
1. Run `dotnet pack SciSharp.TensorFlow.Redist.nupkgproj` under `src/SciSharp.TensorFlow.Redist` directory in Linux. | 1. Run `dotnet pack SciSharp.TensorFlow.Redist.nupkgproj` under `src/SciSharp.TensorFlow.Redist` directory in Linux. | ||||
2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.1.15.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json` | |||||
2. Run `dotnet nuget push SciSharp.TensorFlow.Redist.2.3.0.nupkg -k APIKEY -s https://api.nuget.org/v3/index.json` | |||||
@@ -95,7 +95,7 @@ namespace Tensorflow | |||||
public IEnumerator<(Tensor, Tensor)> GetEnumerator() | public IEnumerator<(Tensor, Tensor)> GetEnumerator() | ||||
{ | { | ||||
var ownedIterator = new OwnedIterator(this); | |||||
using var ownedIterator = new OwnedIterator(this); | |||||
Tensor[] results = null; | Tensor[] results = null; | ||||
while (true) | while (true) | ||||
@@ -8,7 +8,7 @@ namespace Tensorflow | |||||
/// <summary> | /// <summary> | ||||
/// An iterator producing tf.Tensor objects from a tf.data.Dataset. | /// An iterator producing tf.Tensor objects from a tf.data.Dataset. | ||||
/// </summary> | /// </summary> | ||||
public class OwnedIterator : IteratorBase | |||||
public class OwnedIterator : IteratorBase, IDisposable | |||||
{ | { | ||||
IDatasetV2 _dataset; | IDatasetV2 _dataset; | ||||
TensorSpec[] _element_spec; | TensorSpec[] _element_spec; | ||||
@@ -45,5 +45,10 @@ namespace Tensorflow | |||||
throw new StopIteration(ex.Message); | throw new StopIteration(ex.Message); | ||||
} | } | ||||
} | } | ||||
public void Dispose() | |||||
{ | |||||
_resource_deleter.Dispose(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -17,7 +17,7 @@ namespace Tensorflow | |||||
public Initializers initializers { get; } = new Initializers(); | public Initializers initializers { get; } = new Initializers(); | ||||
public LayersApi layers { get; } = new LayersApi(); | public LayersApi layers { get; } = new LayersApi(); | ||||
public Activations activations { get; } = new Activations(); | public Activations activations { get; } = new Activations(); | ||||
public Preprocessing preprocessing { get; } = new Preprocessing(); | |||||
public BackendImpl backend { get; } = new BackendImpl(); | public BackendImpl backend { get; } = new BackendImpl(); | ||||
public Sequential Sequential(List<Layer> layers = null, | public Sequential Sequential(List<Layer> layers = null, | ||||
@@ -1,7 +0,0 @@ | |||||
namespace Tensorflow.Keras | |||||
{ | |||||
public class Preprocessing | |||||
{ | |||||
public Sequence sequence => new Sequence(); | |||||
} | |||||
} |
@@ -0,0 +1,11 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace Tensorflow.Keras.Preprocessings | |||||
{ | |||||
public partial class DatasetUtils | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,33 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace Tensorflow.Keras.Preprocessings | |||||
{ | |||||
public partial class DatasetUtils | |||||
{ | |||||
/// <summary> | |||||
/// Make list of all files in the subdirs of `directory`, with their labels. | |||||
/// </summary> | |||||
/// <param name="directory"></param> | |||||
/// <param name="labels"></param> | |||||
/// <param name="formats"></param> | |||||
/// <param name="class_names"></param> | |||||
/// <param name="shuffle"></param> | |||||
/// <param name="seed"></param> | |||||
/// <param name="follow_links"></param> | |||||
/// <returns> | |||||
/// file_paths, labels, class_names | |||||
/// </returns> | |||||
public (string[], int[], string[]) index_directory(string directory, | |||||
string labels, | |||||
string[] formats, | |||||
string class_names = null, | |||||
bool shuffle = true, | |||||
int? seed = null, | |||||
bool follow_links = false) | |||||
{ | |||||
throw new NotImplementedException(""); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,10 @@ | |||||
using Tensorflow.Keras.Preprocessings; | |||||
namespace Tensorflow.Keras | |||||
{ | |||||
public partial class Preprocessing | |||||
{ | |||||
public Sequence sequence => new Sequence(); | |||||
public DatasetUtils dataset_utils => new DatasetUtils(); | |||||
} | |||||
} |
@@ -0,0 +1,57 @@ | |||||
using System; | |||||
using static Tensorflow.Binding; | |||||
namespace Tensorflow.Keras | |||||
{ | |||||
public partial class Preprocessing | |||||
{ | |||||
public static string[] WHITELIST_FORMATS = new[] { ".bmp", ".gif", ".jpeg", ".jpg", ".png" }; | |||||
/// <summary> | |||||
/// Generates a `tf.data.Dataset` from image files in a directory. | |||||
/// https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image_dataset_from_directory | |||||
/// </summary> | |||||
/// <param name="directory">Directory where the data is located.</param> | |||||
/// <param name="labels"></param> | |||||
/// <param name="label_mode"></param> | |||||
/// <param name="class_names"></param> | |||||
/// <param name="color_mode"></param> | |||||
/// <param name="batch_size"></param> | |||||
/// <param name="image_size"></param> | |||||
/// <param name="shuffle"></param> | |||||
/// <param name="seed"></param> | |||||
/// <param name="validation_split"></param> | |||||
/// <param name="subset"></param> | |||||
/// <param name="interpolation"></param> | |||||
/// <param name="follow_links"></param> | |||||
/// <returns></returns> | |||||
public Tensor image_dataset_from_directory(string directory, | |||||
string labels = "inferred", | |||||
string label_mode = "int", | |||||
string class_names = null, | |||||
string color_mode = "rgb", | |||||
int batch_size = 32, | |||||
TensorShape image_size = null, | |||||
bool shuffle = true, | |||||
int? seed = null, | |||||
float validation_split = 0.2f, | |||||
string subset = null, | |||||
string interpolation = "bilinear", | |||||
bool follow_links = false) | |||||
{ | |||||
int num_channels = 0; | |||||
if (color_mode == "rgb") | |||||
num_channels = 3; | |||||
// C:/Users/haipi/.keras/datasets/flower_photos | |||||
var (image_paths, label_list, class_name_list) = tf.keras.preprocessing.dataset_utils.index_directory(directory, | |||||
labels, | |||||
WHITELIST_FORMATS, | |||||
class_names: class_names, | |||||
shuffle: shuffle, | |||||
seed: seed, | |||||
follow_links: follow_links); | |||||
throw new NotImplementedException(""); | |||||
} | |||||
} | |||||
} |
@@ -37,7 +37,7 @@ PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU | |||||
### Download prebuild binary manually | ### Download prebuild binary manually | ||||
We can't found official prebuild binaries for each platform since tensorflow 2.0. If you know where we can download, please PR here. | |||||
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. | |||||
### Build from source for Windows | ### Build from source for Windows | ||||