From e10e2807afa9cc324a0792a17725778cc4dd8195 Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Sat, 21 Aug 2021 08:29:17 -0500 Subject: [PATCH] Release v0.60.2, change to .net standard 2.0. --- src/TensorFlowNET.Core/NumPy/AutoNumPyAttribute.cs | 3 --- src/TensorFlowNET.Core/Operations/array_ops.cs | 2 +- src/TensorFlowNET.Core/Operations/linalg_ops.cs | 5 +++-- src/TensorFlowNET.Core/Tensorflow.Binding.csproj | 12 ++++++------ src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs | 10 ++++++---- src/TensorFlowNET.Keras/Layers/StackedRNNCells.cs | 3 ++- src/TensorFlowNET.Keras/Tensorflow.Keras.csproj | 8 ++++---- .../Tensorflow.Recommenders.csproj | 4 ++-- src/TensorFlowNET.Text/Tensorflow.Text.csproj | 4 ++-- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/TensorFlowNET.Core/NumPy/AutoNumPyAttribute.cs b/src/TensorFlowNET.Core/NumPy/AutoNumPyAttribute.cs index 6b463960..5a551609 100644 --- a/src/TensorFlowNET.Core/NumPy/AutoNumPyAttribute.cs +++ b/src/TensorFlowNET.Core/NumPy/AutoNumPyAttribute.cs @@ -2,9 +2,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using Tensorflow.Eager; -using Tensorflow.Functions; using static Tensorflow.Binding; namespace Tensorflow.NumPy diff --git a/src/TensorFlowNET.Core/Operations/array_ops.cs b/src/TensorFlowNET.Core/Operations/array_ops.cs index 3dc8cf12..fc83cf4e 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.cs @@ -798,7 +798,7 @@ namespace Tensorflow var output = new List(); foreach (var (i, x) in enumerate(array)) { - var shape = s0[..i].concat(new[] { -1 }).concat(s0[(i + 1)..]); + var shape = s0.Take(i).ToArray().concat(new[] { -1 }).concat(s0.Skip(i + 1).ToArray()); output.add(reshape(stack(x), shape)); } diff --git a/src/TensorFlowNET.Core/Operations/linalg_ops.cs b/src/TensorFlowNET.Core/Operations/linalg_ops.cs index 6a0b869c..b6304899 100644 --- a/src/TensorFlowNET.Core/Operations/linalg_ops.cs +++ b/src/TensorFlowNET.Core/Operations/linalg_ops.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using static Tensorflow.Binding; namespace Tensorflow @@ -53,7 +54,7 @@ namespace Tensorflow Tensor _composite_impl(Tensor matrix, Tensor rhs, Tensor l2_regularizer = null) { - Shape matrix_shape = matrix.shape[^2..]; + Shape matrix_shape = matrix.shape.dims.Skip(matrix.shape.ndim - 2).ToArray(); if (matrix_shape.IsFullyDefined) { if (matrix_shape[-2] >= matrix_shape[-1]) @@ -88,7 +89,7 @@ namespace Tensorflow var small_dim = first_kind ? matrix_shape[-1] : matrix_shape[-2]; var identity = eye(small_dim.numpy(), batch_shape: batch_shape.shape, dtype: matrix.dtype); var small_dim_static = matrix.shape[first_kind ? -1 : -2]; - identity.shape = matrix.shape[..^2].concat(new[] { small_dim_static, small_dim_static }); + identity.shape = matrix.shape.dims.Take(matrix.shape.ndim - 2).ToArray().concat(new[] { small_dim_static, small_dim_static }); gramian += l2_regularizer * identity; } diff --git a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj index b4b5eb4e..33d5b287 100644 --- a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj +++ b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj @@ -1,11 +1,11 @@  - netstandard2.1 + netstandard2.0 TensorFlow.NET Tensorflow 2.2.0 - 0.60.1 + 0.60.2 9.0 enable Haiping Chen, Meinrad Recheis, Eli Belash @@ -20,7 +20,7 @@ Google's TensorFlow full binding in .NET Standard. Building, training and infering deep learning models. https://tensorflownet.readthedocs.io - 0.60.1.0 + 0.60.2.0 tf.net 0.60.x and above are based on tensorflow native 2.6.0 * Eager Mode is added finally. @@ -35,7 +35,7 @@ Keras API is a separate package released as TensorFlow.Keras. tf.net 0.4x.x aligns with TensorFlow v2.4.1 native library. tf.net 0.5x.x aligns with TensorFlow v2.5.x native library. tf.net 0.6x.x aligns with TensorFlow v2.6.x native library. - 0.60.1.0 + 0.60.2.0 LICENSE true true @@ -90,8 +90,8 @@ tf.net 0.6x.x aligns with TensorFlow v2.6.x native library. - + - + diff --git a/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs b/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs index d0d4f5ea..98e02ed3 100644 --- a/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs +++ b/src/TensorFlowNET.Keras/Engine/Model.Evaluate.cs @@ -62,7 +62,7 @@ namespace Tensorflow.Keras.Engine } } - public void evaluate(IDatasetV2 x) + public KeyValuePair[] evaluate(IDatasetV2 x) { data_handler = new DataHandler(new DataHandlerArgs { @@ -72,19 +72,21 @@ namespace Tensorflow.Keras.Engine }); Binding.tf_output_redirect.WriteLine($"Testing..."); + IEnumerable<(string, Tensor)> logs = null; foreach (var (epoch, iterator) in data_handler.enumerate_epochs()) { reset_metrics(); // callbacks.on_epoch_begin(epoch) // data_handler.catch_stop_iteration(); - IEnumerable<(string, Tensor)> results = null; + foreach (var step in data_handler.steps()) { // callbacks.on_train_batch_begin(step) - results = test_function(iterator); + logs = test_function(iterator); } - Binding.tf_output_redirect.WriteLine($"iterator: {epoch + 1}, " + string.Join(", ", results.Select(x => $"{x.Item1}: {(float)x.Item2}"))); + Binding.tf_output_redirect.WriteLine($"iterator: {epoch + 1}, " + string.Join(", ", logs.Select(x => $"{x.Item1}: {(float)x.Item2}"))); } + return logs.Select(x => new KeyValuePair(x.Item1, (float)x.Item2)).ToArray(); } IEnumerable<(string, Tensor)> test_function(OwnedIterator iterator) diff --git a/src/TensorFlowNET.Keras/Layers/StackedRNNCells.cs b/src/TensorFlowNET.Keras/Layers/StackedRNNCells.cs index dad7e0af..2da206ca 100644 --- a/src/TensorFlowNET.Keras/Layers/StackedRNNCells.cs +++ b/src/TensorFlowNET.Keras/Layers/StackedRNNCells.cs @@ -51,7 +51,8 @@ namespace Tensorflow.Keras.Layers } else if (RNN._is_multiple_state(lastCell.state_size)) { - return ((dynamic)Cells[-1].state_size)[0]; + // return ((dynamic)Cells[-1].state_size)[0]; + throw new NotImplementedException(""); } else { diff --git a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj index 90ac4928..2f6eb864 100644 --- a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj +++ b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj @@ -1,13 +1,13 @@  - netstandard2.1 + netstandard2.0 Tensorflow.Keras 9.0 enable Tensorflow.Keras AnyCPU;x64 - 0.6.1 + 0.6.2 Haiping Chen Keras for .NET Apache 2.0, Haiping Chen 2021 @@ -37,8 +37,8 @@ Keras is an API designed for human beings, not machines. Keras follows best prac Git true Open.snk - 0.6.1.0 - 0.6.1.0 + 0.6.2.0 + 0.6.2.0 LICENSE diff --git a/src/TensorFlowNET.Recommenders/Tensorflow.Recommenders.csproj b/src/TensorFlowNET.Recommenders/Tensorflow.Recommenders.csproj index f8e3a953..e3374f95 100644 --- a/src/TensorFlowNET.Recommenders/Tensorflow.Recommenders.csproj +++ b/src/TensorFlowNET.Recommenders/Tensorflow.Recommenders.csproj @@ -1,7 +1,7 @@ - + - netstandard2.1 + netstandard2.0 0.0.1 TensorFlow Recommenders is a library for building recommender system models using TensorFlow. LICENSE diff --git a/src/TensorFlowNET.Text/Tensorflow.Text.csproj b/src/TensorFlowNET.Text/Tensorflow.Text.csproj index 6598fd51..f27f680e 100644 --- a/src/TensorFlowNET.Text/Tensorflow.Text.csproj +++ b/src/TensorFlowNET.Text/Tensorflow.Text.csproj @@ -1,7 +1,7 @@ - + - netstandard2.1 + netstandard2.0 Tensorflow.Text Tensorflow.Text true