[英]How do I clear the shape information of tf.Tensor in TensorFlow?
Suppose during training a network, we resize all images to 512*512, so there might be a tf.Tensor
named input:0
, which is of shape (batch_size, 512, 512, 3)
. 假设在训练网络期间,我们将所有图像的大小调整为512 * 512,因此可能有一个名为
input:0
的tf.Tensor
input:0
,形状为(batch_size, 512, 512, 3)
tf.Tensor
(batch_size, 512, 512, 3)
。
However, when making predictions, it is possible to feed images of multiple sizes into the network. 但是,在进行预测时,可以将多种尺寸的图像输入网络。 So the shape of tensor
input:0
should be something like (batch_size, None, None, 3)
, since the size of images are unknown. 因此张量
input:0
的形状input:0
应该类似于(batch_size, None, None, 3)
,因为图像的大小是未知的。
So if I have a Tensor of shape (batch_size, 512, 512, 3)
, how do I "reshape" it to (batch_size, None, None, 3)
? 因此,如果我有一个Tensor of shape
(batch_size, 512, 512, 3)
,我该如何“重塑”它(batch_size, None, None, 3)
? I tried 我试过了
inputs=tf.reshape(inputs, (batch_size, tf.shape(inputs)[1], tf.shape(inputs)[2], 3)
but the output is still of shape (batch_size, 512, 512, 3)
. 但输出仍然是形状
(batch_size, 512, 512, 3)
。
I don't believe you can resize/rescale the weight/bias terms in a neural network. 我不相信你可以调整/重新调整神经网络中的权重/偏差项。 But it would be pretty easy to resize your image input to 512*512.
但是将图像输入的大小调整为512 * 512非常容易。 Have you considered that?
你考虑过吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.