TensorFlow feed an integer

蹲街弑〆低调 提交于 2019-12-08 03:26:26

I'm not sure that it's the best way, but you can get dynamically the shape of self.input_x in a list with :

input_shape = tf.unpack(tf.shape(self.input_x))

tf.shape(self.input_x) give you a Tensor representing the shape of self.input_x and f.unpack convert it to a list of Tensor.

Now you can create your max pooling node with :

pooled = tf.nn.max_pool(
                h,
                ksize=tf.pack([1, input_size[1] - filter_size + 1, 1, 1]),
                strides=[1, 1, 1, 1],
                padding='VALID',
                name="pool")

(if you needed the 2nd dimension of input_x)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!