2017-08-17 6 views
0

Ich möchte Dekonvolution Layer in Tensorflow für FCN-Modell implementieren, ich habe tf.nn.conv2d_transpose für jeden der 5 Conv-Ausgänge, was ich brauche ist, dass die Ausgabe Form von jedem der 5 deconv ist identisch mit der Eingabebildform. Also setze ichtf.nn.conv2d_transpose output_shape für FCN

deconv_shape = tf.shape(input) 
tf.nn.conv2d_transpose(value=deconv5_1, 
         filter=[32, 32, 1, 1], 
         output_shape=deconv_shape, 
         strides=16, 
         padding="same", 
         name="deconv5_2") 

Mache ich es richtig?

Antwort

0

Ich denke, Ihre Implementierung ist nicht korrekt, hier sind die paar Schritte, um es richtig zu machen.

in_channels = input.shape[-1] 
# here set the output_height, width as [stride*input_height, stride*input_width]] 
output_shape = [batch_size, output_height, output_width, out_channels] 
filter_size =2 # for example 
stride = 2 # for example if you want 2x scale of input height, width 
shape = [filter_size, filter_size, out_channels, in_channels] 
w = tf.get_variable(
     name='W', 
     shape=shape, 
     initializer=w_init, 
     regularizer=w_regularizer, 
     trainable=trainable 
) 

output = tf.nn.conv2d_transpose(
     input, w, output_shape=output_shape, strides=[1, stride, stride, 1]) 
Verwandte Themen