亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法理解:ValueError:圖形已斷開連接:無法獲取張量張量的值

無法理解:ValueError:圖形已斷開連接:無法獲取張量張量的值

慕無忌1623718 2023-07-18 16:57:13
我編寫了類似于此代碼的架構: https ://keras.io/guides/function_api/#manipulate-complex-graph-topologie :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_features, visual_features, et_features],      outputs=[group_pred]      # outputs=[group_pred, score_pred],  )但我收到錯誤: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: []知道為什么嗎?
查看完整描述

1 回答

?
汪汪一只貓

TA貢獻1898條經驗 獲得超8個贊

構建模型時注意正確定義輸入層


他們是inputs=[sentence_encoding_input, visual_features_input, et_features_input]又不是inputs=[sentence_features, visual_features, et_features]


這是完整的模型


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()


查看完整回答
反對 回復 2023-07-18
  • 1 回答
  • 0 關注
  • 182 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號