【发布时间】:2020-06-23 11:09:41
【问题描述】:
我正在按照教程使用 Keras 预训练模型,但出现此错误:
AttributeError: 'tuple' 对象没有属性 'layer'
我在 Google Colab 上运行我的代码,所以我尝试将 TensorFlow 降级到版本 1.x,但问题没有解决。那么我该如何解决呢?
这是我的代码片段:
resnet = ResNet152V2(
include_top=False,
weights="imagenet",
input_shape=(40,40,3)
)
for layer in resnet.layers:
layer.trainable = False
x = resnet.output
x = Flatten()(x)
prediction = Dense(4, activation='softmax')(x)
model = Model(inputs=resnet.input, outputs=prediction)
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
【问题讨论】:
标签: python tensorflow google-colaboratory tensorflow2.0 resnet