我遵循'retrain.py'示例,但得到错误 . 我打印瓶颈张量形状,它是[1,1,1,2048] . 执行“tf.placeholder_with_default(bottleneck_tensor,shape = [None,BOTTLENECK_TENSOR_SIZE],name ='BottleneckInputPlaceholder')时会遇到错误”

似乎bottleneck_tensor是一个4维的张量,每个维度是什么意思?为什么它不是二维张量?

我提到了inception-v3模型的源代码,让我困惑的是我在模型定义中找不到'pool_3'张量,它在retrain.py中使用


Inception-v3模型定义:https://github.com/tensorflow/models/blob/master/inception/inception/slim/inception_model.py

'retrain.py'教程:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py

我的代码:

BOTTLENECK_TENSOR_NAME = 'pool_3:0'
BOTTLENECK_TENSOR_SIZE = 2048
sess = tf.InteractiveSession()
graph = create_inception_graph()
bottleneck_tensor = graph.get_tensor_by_name(ensure_name_has_port(
    BOTTLENECK_TENSOR_NAME))
print bottleneck_tensor.get_shape()

bottleneck_input = tf.placeholder_with_default(
    bottleneck_tensor, shape=[None, BOTTLENECK_TENSOR_SIZE],
    name='BottleneckInputPlaceholder')

错误:

ValueError:形状必须相等,但对于'BottleneckInputPlaceholder'(op:'PlaceholderWithDefault'),形状必须为4和2,输入形状为:[1,1,1,2048] .