2017-04-02 18 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),[学习者])