@@ -137,7 +137,7 @@ public static Tensor zeros(Tensors shape, TF_DataType dtype = TF_DataType.TF_FLO
137
137
if ( shape . Length > 1 )
138
138
{
139
139
shapeTensor = ops . convert_to_tensor ( shape , dtypes . int32 ) ;
140
- if ( shapeTensor . ndim > 1 )
140
+ if ( shapeTensor . ndim > 1 )
141
141
{
142
142
shapeTensor = array_ops . reshape ( shapeTensor , new Shape ( - 1 ) ) ;
143
143
}
@@ -304,6 +304,10 @@ public static Tensor _autopacking_helper(IEnumerable<object> list_or_tuple, TF_D
304
304
{
305
305
elems_as_tensors . Add ( tensor ) ;
306
306
}
307
+ else if ( elem is KerasTensor kt )
308
+ {
309
+ elems_as_tensors . Add ( kt ) ;
310
+ }
307
311
else
308
312
{
309
313
var elem_tensor = constant_op . constant ( elem , dtype : dtype , name : i . ToString ( ) ) ;
@@ -404,7 +408,10 @@ public static Tensor reshape(Tensor tensor, Shape shape, string name = null)
404
408
=> gen_array_ops . reshape ( tensor , shape , name : name ) ;
405
409
406
410
public static Tensor reshape ( Tensor tensor , object [ ] shape , string name = null )
407
- => gen_array_ops . reshape ( tensor , ops . convert_to_tensor ( shape ) , name : name ) ;
411
+ {
412
+ var dims = shape_utils . from_object_array ( shape ) ;
413
+ return gen_array_ops . reshape ( tensor , dims , name : name ) ;
414
+ }
408
415
409
416
private static Tensor ones_like_impl < T > ( T tensor , TF_DataType dtype , string name , bool optimize = true )
410
417
{
@@ -425,6 +432,10 @@ public static Tensor ones(Tensor shape, TF_DataType dtype = TF_DataType.TF_FLOAT
425
432
return tf_with ( ops . name_scope ( name , "ones" , new { shape } ) , scope =>
426
433
{
427
434
name = scope ;
435
+ if ( shape . _shape_tuple ( ) . Length == 0 )
436
+ {
437
+ shape = reshape ( shape , new Shape ( - 1 ) ) ;
438
+ }
428
439
var output = gen_array_ops . fill ( shape , constant_op . constant ( 1.0f , dtype : dtype ) , name : name ) ;
429
440
return output ;
430
441
} ) ;
@@ -647,6 +658,20 @@ public static Tensor tile(Tensor input, Tensor multiples, string name = null)
647
658
}
648
659
} ) ;
649
660
661
+ public static Tensor tile ( Tensor input , object [ ] multiples , string name = null )
662
+ {
663
+ Shape dims = shape_utils . from_object_array ( multiples ) ;
664
+
665
+ return tf . Context . ExecuteOp ( "Tile" , name , new ExecuteOpArgs ( input , dims )
666
+ {
667
+ GetGradientAttrs = ( op ) => new
668
+ {
669
+ T = op . get_attr < TF_DataType > ( "T" ) ,
670
+ Tmultiples = op . get_attr < TF_DataType > ( "Tmultiples" )
671
+ }
672
+ } ) ;
673
+ }
674
+
650
675
public static Tensor zeros_like ( Tensor tensor , TF_DataType dtype = TF_DataType . DtInvalid , string name = null , bool optimize = true )
651
676
{
652
677
return tf_with ( ops . name_scope ( name , "zeros_like" , new Tensor [ ] { tensor } ) , scope =>
0 commit comments