2017-04-02 69 views
1

我的工作CNTK和功能發現ValueError異常綁定佔位符得到了以下錯誤:CNTK:在

ValueError: 2 unbound Placeholder(s) 'Placeholder('keep', [#, *], [939]), Placeholder('keep', [#, *], [939])' found in the Function. All Placeholders of a Function must be bound (to a variable) before performing a Forward computation.

for i in range(10000): 
    a1,a2,tar=get_sample(minibatch_size,start) 
    start=start+int(minibatch_size) 
    if start>=int(0.8*float(len(lab)))-minibatch_size: 
     start=0 
    trainer.train_minibatch({P1: a1, P2: a2, target: tar}) 

P1 and P2 are defined as C.layers.Input(939)

+0

我得到一個類似的錯誤:ValueError異常:1未結合的Placeholder(s)'Placeholder('keep',[???],[???])'在函數中找到。我無法弄清楚爲什麼。 – CodeWarrior

回答

0

我能圖在我的情況下解決問題。我必須將模型輸出而不是模型本身作爲參數傳遞給教練構造函數。

模型= cntk.layers.Sequential([L1,L2])

model_output =模型(預測器)

錯誤: 訓練者= cntk.train.trainer.Trainer(模型,(損失, MEAS),[學習者])

無錯誤: 訓練者= cntk.train.trainer.Trainer(model_output,(損耗,MEAS),[學習者])