From e3c5bb7755c43d8f45d2e2352a6faaf7dcbb7a2b Mon Sep 17 00:00:00 2001 From: Oceania2018 Date: Wed, 10 Apr 2019 06:50:14 -0500 Subject: [PATCH] fix name issue in internal_convert_to_tensor._autopacking_helper --- src/TensorFlowNET.Core/Clustering/KMeans.cs | 5 ++--- src/TensorFlowNET.Core/Operations/array_ops.py.cs | 8 +++++++- src/TensorFlowNET.Core/ops.py.cs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/TensorFlowNET.Core/Clustering/KMeans.cs b/src/TensorFlowNET.Core/Clustering/KMeans.cs index 783a8b71..32a2abaa 100644 --- a/src/TensorFlowNET.Core/Clustering/KMeans.cs +++ b/src/TensorFlowNET.Core/Clustering/KMeans.cs @@ -79,9 +79,8 @@ namespace Tensorflow.Clustering else { var cluster_centers_updated = cluster_centers; - var cluster_counts = _use_mini_batch ? - tf.Variable(array_ops.ones(new Tensor[] { num_clusters }, dtype: TF_DataType.TF_INT64)) : - null; + var ones = array_ops.ones(new Tensor[] { num_clusters }, dtype: TF_DataType.TF_INT64); + var cluster_counts = _use_mini_batch ? tf.Variable(ones) : null; return new RefVariable[] { cluster_centers, diff --git a/src/TensorFlowNET.Core/Operations/array_ops.py.cs b/src/TensorFlowNET.Core/Operations/array_ops.py.cs index 5b6af742..b0f56f8e 100644 --- a/src/TensorFlowNET.Core/Operations/array_ops.py.cs +++ b/src/TensorFlowNET.Core/Operations/array_ops.py.cs @@ -32,6 +32,11 @@ namespace Tensorflow }); } + private static Tensor _constant_if_small(int value, Tensor shape) + { + return shape < 1000; + } + private static Tensor _constant_if_small(T value, Shape shape, TF_DataType dtype, string name) { Tensor tShape = null; @@ -167,8 +172,9 @@ namespace Tensorflow return with(ops.name_scope(name, "ones", new { shape }), scope => { name = scope; + var output = _constant_if_small(1, shape[0]); var shape1 = ops.convert_to_tensor(shape, dtype: TF_DataType.TF_INT32); - var output = gen_array_ops.fill(shape1, constant_op.constant(1, dtype: dtype), name: name); + output = gen_array_ops.fill(shape1, constant_op.constant(1, dtype: dtype), name: name); return output; }); } diff --git a/src/TensorFlowNET.Core/ops.py.cs b/src/TensorFlowNET.Core/ops.py.cs index add752ea..b25122ec 100644 --- a/src/TensorFlowNET.Core/ops.py.cs +++ b/src/TensorFlowNET.Core/ops.py.cs @@ -425,7 +425,7 @@ namespace Tensorflow case Tensor tensor: return tensor; case Tensor[] tensors: - return array_ops._autopacking_helper(tensors, dtype, name); + return array_ops._autopacking_helper(tensors, dtype, name == null ? "packed" : name); case RefVariable varVal: return varVal._TensorConversionFunction(as_ref: as_ref); case object[] objects: