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

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

自定義和預訓練模型的集合給出了運行時錯誤

自定義和預訓練模型的集合給出了運行時錯誤

慕容708150 2021-07-14 17:13:20
我正在嘗試使用帶有 Tensorflow 后端的 Keras(TF:1.9.0 和 Keras:2.1.6)為醫學圖像分類任務創建一個自定義 CNN 和預訓練 VGG16 的集合。在創建集成定義之前,代碼運行良好。在定義整體時,我收到以下錯誤:RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor("input_7:0", shape=(?, 224, 224, 3), dtype=float32) at layer "input_7". The following previous layers were accessed without issue: []我不確定我是否可以通過model_input這種方式傳遞給預訓練的 VGG16。集成定義需要如何修改?
查看完整描述

1 回答

?
慕妹3146593

TA貢獻1820條經驗 獲得超9個贊

問題是 VGG 模型的輸入不是由 的輸入層饋送的ensemble_model。要解決此問題,您需要修改定義ensemble_model并創建一個新的輸入層,然后將其傳遞給兩個模型:


def ensemble(models):

    input_img = Input(shape=input_shape)


    outputs = [model(input_img) for model in models] # get the output of model given the input image

    y = Average()(outputs)


    model = Model(inputs=input_img, outputs=y, name='ensemble')

    return model


ensemble_model = ensemble(models)


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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