Python Can';无法理解:值错误:图形已断开连接:无法获取张量的值

Python Can';无法理解:值错误:图形已断开连接:无法获取张量的值,python,tensorflow,keras,keras-layer,tf.keras,Python,Tensorflow,Keras,Keras Layer,Tf.keras,我编写了一个类似于以下代码的体系结构: : 但我得到了一个错误: ValueError: Graph disconnected: cannot obtain value for tensor Tensor("Sentence-Input-Encoding_2:0", shape=(None, 784), dtype=float32) at layer "sentence_features". The following previous layers we

我编写了一个类似于以下代码的体系结构: :

但我得到了一个错误:

ValueError: Graph disconnected: cannot obtain value for tensor Tensor("Sentence-Input-Encoding_2:0", shape=(None, 784), dtype=float32) at layer "sentence_features". The following previous layers were accessed without issue: []

知道为什么吗?

在构建模型时,请注意正确定义输入层

它们是
输入=[句子编码输入,视觉特征输入,et特征输入]
和非
输入=[句子特征,视觉特征,et特征]

这是完整的模型

from tensorflow import keras
from tensorflow.keras import layers

visual_features_input = keras.Input(
shape=(1000,), name="Visual-Input-FM", dtype='float') 
et_features_input = keras.Input(
  shape=(12,), name="ET-input", dtype='float') 
sentence_encoding_input = keras.Input(
shape=(784,), name="Sentence-Input-Encoding", dtype='float') 

et_features = layers.Dense(units = 12, name = 'et_features')(et_features_input)
visual_features = layers.Dense(units = 100, name = 'visual_features')(visual_features_input)
sentence_features = layers.Dense(units = 60, name = 'sentence_features')(sentence_encoding_input)

x = layers.concatenate([sentence_features, visual_features, et_features], name = 'hybrid-concatenation')

score_pred = layers.Dense(units = 1, name = "score")(x)
group_pred = layers.Dense(units = 5, name="group")(x)

# Instantiate an end-to-end model predicting both score and group
hybrid_model = keras.Model(
  inputs=[sentence_encoding_input, visual_features_input, et_features_input],
  outputs=[group_pred]
  # outputs=[group_pred, score_pred],
)

hybrid_model.summary()

在构建模型时,请注意正确定义输入层

它们是
输入=[句子编码输入,视觉特征输入,et特征输入]
和非
输入=[句子特征,视觉特征,et特征]

这是完整的模型

from tensorflow import keras
from tensorflow.keras import layers

visual_features_input = keras.Input(
shape=(1000,), name="Visual-Input-FM", dtype='float') 
et_features_input = keras.Input(
  shape=(12,), name="ET-input", dtype='float') 
sentence_encoding_input = keras.Input(
shape=(784,), name="Sentence-Input-Encoding", dtype='float') 

et_features = layers.Dense(units = 12, name = 'et_features')(et_features_input)
visual_features = layers.Dense(units = 100, name = 'visual_features')(visual_features_input)
sentence_features = layers.Dense(units = 60, name = 'sentence_features')(sentence_encoding_input)

x = layers.concatenate([sentence_features, visual_features, et_features], name = 'hybrid-concatenation')

score_pred = layers.Dense(units = 1, name = "score")(x)
group_pred = layers.Dense(units = 5, name="group")(x)

# Instantiate an end-to-end model predicting both score and group
hybrid_model = keras.Model(
  inputs=[sentence_encoding_input, visual_features_input, et_features_input],
  outputs=[group_pred]
  # outputs=[group_pred, score_pred],
)

hybrid_model.summary()