@@ -21,6 +21,31 @@ namespace Tensorflow
2121{
2222 public class nn_impl
2323 {
24+ public static Tensor conv2d_transpose ( Tensor value = null ,
25+ IVariableV1 filter = null ,
26+ Tensor output_shape = null ,
27+ TensorShape strides = null ,
28+ string padding = "SAME" ,
29+ string data_format = "NHWC" ,
30+ string name = null ,
31+ TensorShape dilations = null )
32+ {
33+ if ( dilations == null )
34+ dilations = ( 1 , 1 , 1 , 1 ) ;
35+ return tf_with ( ops . name_scope ( name , "conv2d_transpose" , new { value , filter , output_shape } ) , scope =>
36+ {
37+ return gen_nn_ops . conv2d_backprop_input (
38+ input_sizes : output_shape ,
39+ filter : filter . AsTensor ( ) ,
40+ out_backprop : value ,
41+ strides : strides ,
42+ padding : padding ,
43+ data_format : data_format ,
44+ dilations : dilations ,
45+ name : name ) ;
46+ } ) ;
47+ }
48+
2449 /// <summary>
2550 /// Normalizes along dimension `axis` using an L2 norm.
2651 /// </summary>
@@ -83,6 +108,23 @@ public static (Tensor, Tensor) moments(Tensor x,
83108 } ) ;
84109 }
85110
111+ public static Tensor batch_normalization ( Tensor x ,
112+ Tensor mean ,
113+ Tensor variance ,
114+ Tensor offset ,
115+ Tensor scale ,
116+ float variance_epsilon = 0.001f ,
117+ string name = null )
118+ {
119+ return tf_with ( ops . name_scope ( name , "batchnorm" , new { x , mean , variance , scale , offset } ) , scope =>
120+ {
121+ var inv = math_ops . rsqrt ( variance + variance_epsilon ) ;
122+ inv *= scale ;
123+ return x * math_ops . cast ( inv , x . dtype ) + math_ops . cast (
124+ offset == null ? ( - mean * inv ) : ( offset - mean * inv ) , x . dtype ) ;
125+ } ) ;
126+ }
127+
86128 /// <summary>
87129 /// Batch normalization.
88130 /// </summary>
0 commit comments