[英]Shapes must be equal rank
I'd like to do transfer learning from a pre-trained model. 我想从预先训练的模型中进行转移学习。 I'm following the guide for retrain from Tensorflow. 我正在遵循Tensorflow的再培训指南 。
However, I'm stuck in an error tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes must be equal rank, but are 3 and 2 for 'input_1/BottleneckInputPlaceholder' (op: 'PlaceholderWithDefault') with input shapes: [1,?,128].
但是,我陷入了一个错误tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes must be equal rank, but are 3 and 2 for 'input_1/BottleneckInputPlaceholder' (op: 'PlaceholderWithDefault') with input shapes: [1,?,128].
# Last layer of pre-trained model
# `[<tf.Tensor 'embeddings:0' shape=(?, 128) dtype=float32>]`
with tf.name_scope('input'):
bottleneck_input = tf.placeholder_with_default(
bottleneck_tensor,
shape=[None, 128],
name='BottleneckInputPlaceholder')
Any ideas? 有任何想法吗?
This is happening because your bottleneck_tensor
is of shape [1, ?, 128]
and you are explicitly stating that the shape should be [?, 128]
. 发生这种情况是因为您的bottleneck_tensor
的形状为[1, ?, 128]
并且您明确声明该形状应为[?, 128]
。 You can use tf.squeeze
to reduce convert your tensor in the required shape as 您可以使用tf.squeeze
减少将张量转换为所需形状
tf.squeeze(bottleneck_tensor)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.