Tensorflow: use None in output_shape in conv2D_transpose

I would like to use conv2d_tranpose(or deconvolution) instead of increasing the sampling rate on my network. For this, you need to pass output_shapea function call. This is not a problem, I can calculate it. But I would like to use None for batch_size to maintain installation flexibility. Is it possible?

Here is the line of code:

tf.nn.conv2d_transpose(hd_conv1, Wd_conv1, [batch_size, 14,14,64], strides=[1,2,2,1], padding="SAME")

batch_sizeis just a variable that I set at the top of my script. This code works fine, but if I use Noneinstead batch_size:

TypeError: expected binary or unicode string not received

If I just leave the first dimension:

ValueError: output_shape must be of the form (4,), got (3,)

It seems strange to me that there are different ways to deal with batch_size. Some operations simply ignore it, for example, regular conv2d, but here I need to explicitly specify it. In any case, I wondered why I should calculate output_shape myself. With the given inputs, steps, laying, which should be easily counted. There is a github issue regarding the output of output_shape, unfortunately it seems like no further action is happening.

Am I doing it right - passing explicit batch_sizeto output_shape? Is there any way to omit explicit batch_size?

+4
source share
1 answer

None , .

batch_size = tf.shape(something_or_other)[0]  
deconv_shape = tf.pack([batch_size, 40, 40, 32])  
conv2d_transpose(..., output_shape=deconv_shape, ...)  

tf.get_shape(). tf.get_shape() tf.shape() .

. tensorflow .

https://www.tensorflow.org/programmers_guide/faq

+2

Source: https://habr.com/ru/post/1660919/


All Articles