Skip to content

Commit b821d82

Browse files
committed
release preview4.
1 parent a3cf7ae commit b821d82

File tree

10 files changed

+121
-12
lines changed

10 files changed

+121
-12
lines changed

src/SciSharp.TensorFlow.Redist/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ Related merged [commits](https://github.com/SciSharp/TensorFlow.NET/commit/854a5
2727
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.
2828

2929
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`
3131

3232

src/TensorFlowNET.Core/Data/DatasetV2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override string ToString()
9595

9696
public IEnumerator<(Tensor, Tensor)> GetEnumerator()
9797
{
98-
var ownedIterator = new OwnedIterator(this);
98+
using var ownedIterator = new OwnedIterator(this);
9999

100100
Tensor[] results = null;
101101
while (true)

src/TensorFlowNET.Core/Data/OwnedIterator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Tensorflow
88
/// <summary>
99
/// An iterator producing tf.Tensor objects from a tf.data.Dataset.
1010
/// </summary>
11-
public class OwnedIterator : IteratorBase
11+
public class OwnedIterator : IteratorBase, IDisposable
1212
{
1313
IDatasetV2 _dataset;
1414
TensorSpec[] _element_spec;
@@ -45,5 +45,10 @@ public Tensor[] next()
4545
throw new StopIteration(ex.Message);
4646
}
4747
}
48+
49+
public void Dispose()
50+
{
51+
_resource_deleter.Dispose();
52+
}
4853
}
4954
}

src/TensorFlowNET.Core/Keras/KerasApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class KerasApi
1717
public Initializers initializers { get; } = new Initializers();
1818
public LayersApi layers { get; } = new LayersApi();
1919
public Activations activations { get; } = new Activations();
20-
20+
public Preprocessing preprocessing { get; } = new Preprocessing();
2121
public BackendImpl backend { get; } = new BackendImpl();
2222

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

src/TensorFlowNET.Core/Keras/Preprocessing.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

tensorflowlib/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PM> Install-Package SciSharp.TensorFlow.Redist-Linux-GPU
3737

3838
### Download prebuild binary manually
3939

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

4242

4343
### Build from source for Windows

0 commit comments

Comments
 (0)