@@ -79,9 +79,8 @@ namespace Tensorflow.Clustering | |||||
else | else | ||||
{ | { | ||||
var cluster_centers_updated = cluster_centers; | 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[] | return new RefVariable[] | ||||
{ | { | ||||
cluster_centers, | cluster_centers, | ||||
@@ -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>(T value, Shape shape, TF_DataType dtype, string name) | private static Tensor _constant_if_small<T>(T value, Shape shape, TF_DataType dtype, string name) | ||||
{ | { | ||||
Tensor tShape = null; | Tensor tShape = null; | ||||
@@ -167,8 +172,9 @@ namespace Tensorflow | |||||
return with(ops.name_scope(name, "ones", new { shape }), scope => | return with(ops.name_scope(name, "ones", new { shape }), scope => | ||||
{ | { | ||||
name = scope; | name = scope; | ||||
var output = _constant_if_small(1, shape[0]); | |||||
var shape1 = ops.convert_to_tensor(shape, dtype: TF_DataType.TF_INT32); | 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; | return output; | ||||
}); | }); | ||||
} | } | ||||
@@ -425,7 +425,7 @@ namespace Tensorflow | |||||
case Tensor tensor: | case Tensor tensor: | ||||
return tensor; | return tensor; | ||||
case Tensor[] tensors: | 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: | case RefVariable varVal: | ||||
return varVal._TensorConversionFunction(as_ref: as_ref); | return varVal._TensorConversionFunction(as_ref: as_ref); | ||||
case object[] objects: | case object[] objects: | ||||