keras 尝试从inceptionv3体系结构中提取特征时出现图形断开错误

2w3rbyxf  于 2024-01-08  发布在  其他
关注(0)|答案(1)|浏览(152)

我试图从架构的中间提取一些特征,并将其用于另一个模型。

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

字符串
在尝试这样做时,我得到以下错误,可能的原因是什么?

  1. 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: []

von4xj4u

von4xj4u1#

您遇到的错误“Graph disconnected:cannot obtain value for KerasTensor”表明模型中层的连接性存在问题。
若要解决此问题,请使用 tf.keras.utils.plot_model(model,show_shapes=True,show_dtype=True) 可视化图形,确保将输入Tensor正确连接到模型中的层。
这将有助于发现图中不连接的部分或模型架构中的错误。

相关问题