diff --git a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
index d3433ee2..e23e8aa5 100644
--- a/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
+++ b/src/TensorFlowNET.Core/Eager/EagerTensor.Creation.cs
@@ -37,15 +37,8 @@ namespace Tensorflow.Eager
=> NewEagerTensorHandle(_handle);
#endregion
- public EagerTensor(object value,string device_name, TF_DataType dtype = TF_DataType.TF_UINT8) : base((float[])value)
- {
- throw new NotImplementedException("");
- }
-
public EagerTensor(object value, Shape? shape = null, string device_name = null, TF_DataType dtype = TF_DataType.TF_UINT8) : base((float[])value)
- {
- NewEagerTensorHandle(_handle);
- }
+ => NewEagerTensorHandle(_handle);
public EagerTensor(Shape shape, TF_DataType dtype) : base(shape, dtype)
=> NewEagerTensorHandle(_handle);
@@ -56,6 +49,9 @@ namespace Tensorflow.Eager
public EagerTensor(byte[] bytes, Shape shape, TF_DataType dtype) : base(bytes, shape, dtype)
=> NewEagerTensorHandle(_handle);
+ public EagerTensor(IntPtr data_ptr, Shape shape, TF_DataType dtype) : base(data_ptr, shape, dtype)
+ => NewEagerTensorHandle(_handle);
+
void NewEagerTensorHandle(SafeTensorHandle h)
{
_id = ops.uid();
diff --git a/src/TensorFlowNET.Core/Gradients/image_grad.cs b/src/TensorFlowNET.Core/Gradients/image_grad.cs
index 3c26f389..7b5fb521 100644
--- a/src/TensorFlowNET.Core/Gradients/image_grad.cs
+++ b/src/TensorFlowNET.Core/Gradients/image_grad.cs
@@ -30,7 +30,7 @@ namespace Tensorflow.Gradients
var shape = new Shape(image.shape.dims.Skip(1).Take(2).ToArray());
Tensor image_shape = null;
if (shape.IsFullyDefined)
- image_shape = constant_op.constant(image.shape.dims.Skip(1).Take(2).ToArray());
+ image_shape = constant_op.constant(image.shape.as_int_list().Skip(1).Take(2).ToArray());
else
image_shape = array_ops.shape(image)["1:3"];
diff --git a/src/TensorFlowNET.Core/Gradients/math_grad.cs b/src/TensorFlowNET.Core/Gradients/math_grad.cs
index 60408bab..ee92b4ea 100644
--- a/src/TensorFlowNET.Core/Gradients/math_grad.cs
+++ b/src/TensorFlowNET.Core/Gradients/math_grad.cs
@@ -694,6 +694,20 @@ namespace Tensorflow.Gradients
});
}
+ [RegisterGradient("Cast")]
+ public static Tensor[] _CastGrad(Operation op, Tensor[] grads)
+ {
+ var grad = grads[0];
+ var x = op.inputs[0];
+
+ var src_type = x.dtype.as_base_dtype();
+ var dst_type = grad.dtype.as_base_dtype();
+ if (src_type.is_value_dtype() && dst_type.is_value_dtype())
+ return new Tensor[] { math_ops.cast(grad, src_type) };
+ else
+ return new Tensor[0];
+ }
+
[RegisterGradient("Cos")]
public static Tensor[] _CosGrad(Operation op, Tensor[] grads)
{
diff --git a/src/TensorFlowNET.Core/NumPy/Numpy.Math.cs b/src/TensorFlowNET.Core/NumPy/Numpy.Math.cs
index 9d78137f..b4f1e2f9 100644
--- a/src/TensorFlowNET.Core/NumPy/Numpy.Math.cs
+++ b/src/TensorFlowNET.Core/NumPy/Numpy.Math.cs
@@ -13,7 +13,7 @@ namespace Tensorflow.NumPy
public static NDArray exp(NDArray x) => new NDArray(tf.exp(x));
[AutoNumPy]
- public static NDArray floor(NDArray x) => new NDArray(tf.floor(x));
+ public static NDArray floor(NDArray x) => new NDArray(math_ops.floor(x));
[AutoNumPy]
public static NDArray log(NDArray x) => new NDArray(tf.log(x));
diff --git a/src/TensorFlowNET.Core/Operations/math_ops.cs b/src/TensorFlowNET.Core/Operations/math_ops.cs
index acd147ee..71992f35 100644
--- a/src/TensorFlowNET.Core/Operations/math_ops.cs
+++ b/src/TensorFlowNET.Core/Operations/math_ops.cs
@@ -720,6 +720,8 @@ namespace Tensorflow
return gen_math_ops.range(start1, limit1, delta1, name);
});
}
+ public static Tensor floor(Tensor x, string name = null)
+ => tf.Context.ExecuteOp("Floor", name, new ExecuteOpArgs(x));
public static Tensor floordiv(Tensor x, Tensor y, string name = null)
{
diff --git a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
index 7a52fada..b4b5eb4e 100644
--- a/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
+++ b/src/TensorFlowNET.Core/Tensorflow.Binding.csproj
@@ -5,7 +5,7 @@
TensorFlow.NET
Tensorflow
2.2.0
- 0.60.0
+ 0.60.1
9.0
enable
Haiping Chen, Meinrad Recheis, Eli Belash
@@ -20,8 +20,8 @@
Google's TensorFlow full binding in .NET Standard.
Building, training and infering deep learning models.
https://tensorflownet.readthedocs.io
- 0.60.0.0
- tf.net 0.20.x and above are based on tensorflow native 2.x.
+ 0.60.1.0
+ tf.net 0.60.x and above are based on tensorflow native 2.6.0
* Eager Mode is added finally.
* tf.keras is partially working.
@@ -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.0.0
+ 0.60.1.0
LICENSE
true
true
diff --git a/src/TensorFlowNET.Core/Tensors/Tensors.cs b/src/TensorFlowNET.Core/Tensors/Tensors.cs
index c1d59e39..2c3ea4fd 100644
--- a/src/TensorFlowNET.Core/Tensors/Tensors.cs
+++ b/src/TensorFlowNET.Core/Tensors/Tensors.cs
@@ -79,6 +79,7 @@ namespace Tensorflow
public static implicit operator Tensors((Tensor, Tensor) tuple)
=> new Tensors(tuple.Item1, tuple.Item2);
+ [AutoNumPy]
public static implicit operator Tensors(NDArray nd)
=> new Tensors(nd);
diff --git a/src/TensorFlowNET.Core/Tensors/dtypes.cs b/src/TensorFlowNET.Core/Tensors/dtypes.cs
index cfc0a980..7c3a291c 100644
--- a/src/TensorFlowNET.Core/Tensors/dtypes.cs
+++ b/src/TensorFlowNET.Core/Tensors/dtypes.cs
@@ -138,7 +138,8 @@ namespace Tensorflow
dtype = TF_DataType.TF_BOOL;
break;
default:
- throw new NotSupportedException($"Unable to convert {type} to a TensorFlow data type.");
+ dtype = TF_DataType.DtInvalid;
+ break;
}
return dtype;
diff --git a/src/TensorFlowNET.Core/ops.cs b/src/TensorFlowNET.Core/ops.cs
index f499574f..5123477a 100644
--- a/src/TensorFlowNET.Core/ops.cs
+++ b/src/TensorFlowNET.Core/ops.cs
@@ -165,7 +165,7 @@ namespace Tensorflow
if (dtype == TF_DataType.TF_STRING)
return ret;
- if (dtype.as_base_dtype() != ret.dtype.as_base_dtype())
+ if (dtype != TF_DataType.DtInvalid && dtype.as_base_dtype() != ret.dtype.as_base_dtype())
ret = gen_math_ops.cast(ret, dtype, name: name);
return ret;
diff --git a/src/TensorFlowNET.Keras/Engine/Model.Training.cs b/src/TensorFlowNET.Keras/Engine/Model.Training.cs
index 02dccc92..c15d3411 100644
--- a/src/TensorFlowNET.Keras/Engine/Model.Training.cs
+++ b/src/TensorFlowNET.Keras/Engine/Model.Training.cs
@@ -4,6 +4,7 @@ using System.Text;
using HDF.PInvoke;
using HDF5CSharp;
using Tensorflow.NumPy;
+using static Tensorflow.Binding;
using Tensorflow.Keras.Saving;
namespace Tensorflow.Keras.Engine
@@ -14,7 +15,11 @@ namespace Tensorflow.Keras.Engine
public void load_weights(string filepath, bool by_name = false, bool skip_mismatch = false, object options = null)
{
long fileId = Hdf5.OpenFile(filepath, true);
-
+ if(fileId < 0)
+ {
+ tf_output_redirect.WriteLine($"Can't find weights file {filepath}");
+ return;
+ }
bool msuccess = Hdf5.GroupExists(fileId, "model_weights");
bool lsuccess = Hdf5.GroupExists(fileId, "layer_names");
diff --git a/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
index d7eee230..80aaa98e 100644
--- a/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
+++ b/src/TensorFlowNET.Keras/Preprocessings/Preprocessing.paths_and_labels_to_dataset.cs
@@ -26,12 +26,12 @@ namespace Tensorflow.Keras
images[i] = resized_image.numpy();
tf_output_redirect.WriteLine(image_paths[i]);
};
+ var img_ds = tf.data.Dataset.from_tensor_slices(images);
// option 2: dynamic load, but has error, need to fix
- /* var path_ds = tf.data.Dataset.from_tensor_slices(image_paths);
- var img_ds = path_ds.map(x => path_to_image(x, image_size, num_channels, interpolation));*/
-
- var img_ds = tf.data.Dataset.from_tensor_slices(images);
+ // var path_ds = tf.data.Dataset.from_tensor_slices(image_paths);
+ // var img_ds = path_ds.map(x => path_to_image(x, image_size, num_channels, interpolation));
+
if (label_mode == "int")
{
var label_ds = dataset_utils.labels_to_dataset(labels, label_mode, num_classes);
@@ -43,6 +43,7 @@ namespace Tensorflow.Keras
Tensor path_to_image(Tensor path, Shape image_size, int num_channels, string interpolation)
{
+ tf.print(path);
var img = tf.io.read_file(path);
img = tf.image.decode_image(
img, channels: num_channels, expand_animations: false);
@@ -57,8 +58,18 @@ namespace Tensorflow.Keras
int num_classes,
int max_length = -1)
{
- var path_ds = tf.data.Dataset.from_tensor_slices(image_paths);
- var string_ds = path_ds.map(x => path_to_string_content(x, max_length));
+ var text = new string[image_paths.Length];
+ for (int i = 0; i < text.Length; i++)
+ {
+ text[i] = File.ReadAllText(image_paths[i]);
+ tf_output_redirect.WriteLine(image_paths[i]);
+ }
+
+ var images = np.array(text);
+ var string_ds = tf.data.Dataset.from_tensor_slices(images);
+
+ // var path_ds = tf.data.Dataset.from_tensor_slices(image_paths);
+ // var string_ds = path_ds.map(x => path_to_string_content(x, max_length));
if (label_mode == "int")
{
diff --git a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
index eefa8b41..90ac4928 100644
--- a/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
+++ b/src/TensorFlowNET.Keras/Tensorflow.Keras.csproj
@@ -7,7 +7,7 @@
enable
Tensorflow.Keras
AnyCPU;x64
- 0.6.0
+ 0.6.1
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.0.0
- 0.6.0.0
+ 0.6.1.0
+ 0.6.1.0
LICENSE