Skip to content

Commit e3c5bb7

Browse files
committed
fix name issue in internal_convert_to_tensor._autopacking_helper
1 parent 9f54715 commit e3c5bb7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/TensorFlowNET.Core/Clustering/KMeans.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ private RefVariable[] _create_variables(Tensor num_clusters)
7979
else
8080
{
8181
var cluster_centers_updated = cluster_centers;
82-
var cluster_counts = _use_mini_batch ?
83-
tf.Variable(array_ops.ones(new Tensor[] { num_clusters }, dtype: TF_DataType.TF_INT64)) :
84-
null;
82+
var ones = array_ops.ones(new Tensor[] { num_clusters }, dtype: TF_DataType.TF_INT64);
83+
var cluster_counts = _use_mini_batch ? tf.Variable(ones) : null;
8584
return new RefVariable[]
8685
{
8786
cluster_centers,

src/TensorFlowNET.Core/Operations/array_ops.py.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public static Tensor zeros(Shape shape, TF_DataType dtype = TF_DataType.TF_FLOAT
3232
});
3333
}
3434

35+
private static Tensor _constant_if_small(int value, Tensor shape)
36+
{
37+
return shape < 1000;
38+
}
39+
3540
private static Tensor _constant_if_small<T>(T value, Shape shape, TF_DataType dtype, string name)
3641
{
3742
Tensor tShape = null;
@@ -167,8 +172,9 @@ public static Tensor ones(Tensor[] shape, TF_DataType dtype = TF_DataType.TF_FLO
167172
return with(ops.name_scope(name, "ones", new { shape }), scope =>
168173
{
169174
name = scope;
175+
var output = _constant_if_small(1, shape[0]);
170176
var shape1 = ops.convert_to_tensor(shape, dtype: TF_DataType.TF_INT32);
171-
var output = gen_array_ops.fill(shape1, constant_op.constant(1, dtype: dtype), name: name);
177+
output = gen_array_ops.fill(shape1, constant_op.constant(1, dtype: dtype), name: name);
172178
return output;
173179
});
174180
}

src/TensorFlowNET.Core/ops.py.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public static Tensor internal_convert_to_tensor(object value, TF_DataType dtype
425425
case Tensor tensor:
426426
return tensor;
427427
case Tensor[] tensors:
428-
return array_ops._autopacking_helper(tensors, dtype, name);
428+
return array_ops._autopacking_helper(tensors, dtype, name == null ? "packed" : name);
429429
case RefVariable varVal:
430430
return varVal._TensorConversionFunction(as_ref: as_ref);
431431
case object[] objects:

0 commit comments

Comments
 (0)