简体   繁体   English

形状必须相等

[英]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.

相关问题 tf.gradients: ValueError: Shapes must be equal rank, but are 2 and 1 - tf.gradients: ValueError: Shapes must be equal rank, but are 2 and 1 Tensorflow:形状必须等于等级,但对于tf.norm来说形状必须为4和1, - Tensorflow : Shapes must be equal rank, but are 4 and 1, for tf.norm Keras LSTM TensorFlow错误:“形状必须等于等级,但必须为1和0” - Keras LSTM TensorFlow Error: 'Shapes must be equal rank, but are 1 and 0' Tensorflow LSTM错误(ValueError:形状必须等于等级,但为2和1) - Tensorflow LSTM Error (ValueError: Shapes must be equal rank, but are 2 and 1 ) tensor_scatter_nd_update ValueError: Shapes must be equal rank, but are 0 and 1 - tensor_scatter_nd_update ValueError: Shapes must be equal rank, but are 0 and 1 Tensorflow错误:ValueError:形状必须等于等级,但是2和1从形状1与其他形状合并 - Tensorflow Error: ValueError: Shapes must be equal rank, but are 2 and 1 From merging shape 1 with other shapes ValueError: Shapes must be equal rank, but are 1 and 0 从将形状 1 与其他形状合并。 对于“损失/添加” - ValueError: Shapes must be equal rank, but are 1 and 0 From merging shape 1 with other shapes. for 'loss/AddN' 两个形状的维度 2 必须相等,但是是 3 和 1 - Dimension 2 in both shapes must be equal, but are 3 and 1 ValueError:形状必须为 0 级,但对于“ReadFile”(操作:“ReadFile”)为 1 级,输入形状为:[1] - ValueError: Shape must be rank 0 but is rank 1 for 'ReadFile' (op: 'ReadFile') with input shapes: [1] tensorflow ValueError:两个形状的尺寸0必须相等 - tensorflow ValueError: Dimension 0 in both shapes must be equal
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM