[問題] keras model問題

看板Python作者 (QQ)時間7年前 (2018/06/09 01:56), 編輯推噓3(305)
留言8則, 5人參與, 7年前最新討論串1/1
想請教一個簡單的model問題如下 def generator(): input = Input(shape=(100,)) y = Dense(300,activation = "relu")(input) y = Dense(500,activation = "relu")(y) y = Dense(784,activation = "relu")(y) return Model(input,y) 以上就只是個簡單的model 問題來了: Case I:(成功) ori_model = generator() y = ori_model.output model = Model(ori_model.input, y) Case II:(失敗) generator() y = generator().output model = Model(generator().input, y) =================================== 我想知道Case II失敗的詳細原因 目前我只能說出個籠統的說法是,沒有先令一個變數的話(像caseI令成ori_model) code並不知道要去找同一個model,而會去重複call generator()導致tf.graph接不上 但是這說法也只是我有了case I,II的比較才得出的 想求教詳細的原因,感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.68.160.241 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1528480574.A.CF8.html

06/09 04:28, 7年前 , 1F
原因就是你說的
06/09 04:28, 1F

06/09 04:28, 7年前 , 2F
真有趣, 大部份初學者的問題都是恰好相反 -- 重覆call
06/09 04:28, 2F

06/09 04:29, 7年前 , 3F
同一個函數而不做暫存, 你的問題剛好反過來..
06/09 04:29, 3F

06/09 18:11, 7年前 , 4F
你創了兩個model A B,你拿A的頭去接B的尾巴
06/09 18:11, 4F

06/10 19:29, 7年前 , 5F
可以去資料科學版問
06/10 19:29, 5F

06/11 00:47, 7年前 , 6F
好 謝謝!
06/11 00:47, 6F

06/11 11:04, 7年前 , 7F
真不愧是史上最強初學者
06/11 11:04, 7F

06/11 11:39, 7年前 , 8F
去屎!
06/11 11:39, 8F
文章代碼(AID): #1R6iC-pu (Python)
文章代碼(AID): #1R6iC-pu (Python)