尝试从 inceptionv3 架构中提取特征时出现图形断开错误

问题描述 投票:0回答:1

我正在尝试从架构中间提取一些特征并将其用于另一个模型。

base_model = InceptionV3(weights='imagenet', include_top=False)
input_tensor = Input(shape=(299, 299, 3))  # Input shape for InceptionV3
InceptionA_feature_extractor = models.Model(inputs=input_tensor, outputs=base_model.get_layer('mixed2').output)

尝试执行此操作时,我收到以下错误,可能的原因是什么?

ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, None, None, 3), dtype=tf.float32, name='input_6'), name='input_6', description="created by layer 'input_6'") at layer "conv2d_376". The following previous layers were accessed without issue: []
python machine-learning keras deep-learning computer-vision
1个回答
0
投票

您遇到的错误“图形已断开连接:无法获取 KerasTensor 的值”表明模型中各层的连接存在问题。

要解决此问题,请确保通过使用 tf.keras.utils.plot_model(model, show_shapes=True, show_dtype=True) 可视化图形,将输入张量正确连接到模型中的层。

这将有助于找到图表中断开的部分或模型架构中的错误。

© www.soinside.com 2019 - 2024. All rights reserved.