Browse Source

release preview4.

tags/v0.20
Oceania2018 5 years ago
parent
commit
b821d82d4f
10 changed files with 121 additions and 12 deletions
  1. +1
    -1
      src/SciSharp.TensorFlow.Redist/README.md
  2. +1
    -1
      src/TensorFlowNET.Core/Data/DatasetV2.cs
  3. +6
    -1
      src/TensorFlowNET.Core/Data/OwnedIterator.cs
  4. +1
    -1
      src/TensorFlowNET.Core/Keras/KerasApi.cs
  5. +0
    -7
      src/TensorFlowNET.Core/Keras/Preprocessing.cs
  6. +11
    -0
      src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs
  7. +33
    -0
      src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs
  8. +10
    -0
      src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.cs
  9. +57
    -0
      src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs
  10. +1
    -1
      tensorflowlib/README.md

+ 1
- 1
src/SciSharp.TensorFlow.Redist/README.md View File

@@ -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.

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`



+ 1
- 1
src/TensorFlowNET.Core/Data/DatasetV2.cs View File

@@ -95,7 +95,7 @@ namespace Tensorflow

public IEnumerator<(Tensor, Tensor)> GetEnumerator()
{
var ownedIterator = new OwnedIterator(this);
using var ownedIterator = new OwnedIterator(this);

Tensor[] results = null;
while (true)


+ 6
- 1
src/TensorFlowNET.Core/Data/OwnedIterator.cs View File

@@ -8,7 +8,7 @@ namespace Tensorflow
/// <summary>
/// An iterator producing tf.Tensor objects from a tf.data.Dataset.
/// </summary>
public class OwnedIterator : IteratorBase
public class OwnedIterator : IteratorBase, IDisposable
{
IDatasetV2 _dataset;
TensorSpec[] _element_spec;
@@ -45,5 +45,10 @@ namespace Tensorflow
throw new StopIteration(ex.Message);
}
}

public void Dispose()
{
_resource_deleter.Dispose();
}
}
}

+ 1
- 1
src/TensorFlowNET.Core/Keras/KerasApi.cs View File

@@ -17,7 +17,7 @@ namespace Tensorflow
public Initializers initializers { get; } = new Initializers();
public LayersApi layers { get; } = new LayersApi();
public Activations activations { get; } = new Activations();
public Preprocessing preprocessing { get; } = new Preprocessing();
public BackendImpl backend { get; } = new BackendImpl();

public Sequential Sequential(List<Layer> layers = null,


+ 0
- 7
src/TensorFlowNET.Core/Keras/Preprocessing.cs View File

@@ -1,7 +0,0 @@
namespace Tensorflow.Keras
{
public class Preprocessing
{
public Sequence sequence => new Sequence();
}
}

+ 11
- 0
src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.cs View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Keras.Preprocessings
{
public partial class DatasetUtils
{

}
}

+ 33
- 0
src/TensorFlowNET.Core/Keras/Preprocessings/DatasetUtils.index_directory.cs View File

@@ -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("");
}
}
}

+ 10
- 0
src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.cs View File

@@ -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();
}
}

+ 57
- 0
src/TensorFlowNET.Core/Keras/Preprocessings/Preprocessing.image_dataset_from_directory.cs View File

@@ -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("");
}
}
}

+ 1
- 1
tensorflowlib/README.md View File

@@ -37,7 +37,7 @@ PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU

### 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


Loading…
Cancel
Save