注: 本文是作者的自我總結,主要作為個人總結記錄, 歡迎大家批評,交流. https://zhouxiaowei1120.github.io/#blogs
大家可能都知道, 在tensorflow中, 如果想實現測試時的batchsize大小隨意設置, 那么在訓練時, 輸入的placeholder的shape應該設置為[None, H, W, C]. 具體代碼如下所示:
# Placeholders for input data and the targets
x_input = tf.placeholder(dtype=tf.float32, shape=[None, input_dim[0],input_dim[1],input_dim[2]], name='Input')
y_input = tf.placeholder(dtype=tf.float32, shape=[None, n_labels], name='Labels')
s_map = tf.placeholder(dtype=tf.float32,shape=[None,z_dim[0],z_dim[1],z_dim[2]], name='S_map')
x_target = tf.placeholder(dtype=tf.float32, shape=[None, input_dim[0],input_dim[1],input_dim[2]], name='Target')
test_encoder_input = tf.placeholder(dtype=tf.float32, shape=[None, input_dim[0],input_dim[1],input_dim[2]], name='Encoder_input')
然而, 如果設計的模型中, 有轉置卷積網絡, 其中用到了tf.nn.conv2d_transpose()函數, 那么該函數中的output_shape, 需要按照如下形式進行設置:
x = tf.nn.conv2d_transpose(x,w_t3,output_shape=tf.stack([tf.shape(x)[0],z_dim[0],z_dim[1],z_dim[2]]),strides=(1,8,8,1),padding='SAME',name='e_convt3')
Reference: https://groups.google.com/a/tensorflow.org/forum/#!topic/discuss/vf8eH9YMwVA
---------------------
作者:davefighting
來源:CSDN
原文:https://blog.csdn.net/zhouxiaowei1120/article/details/85699468
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!