gpt4 book ai didi

python - CNTK运行时错误

转载 作者:行者123 更新时间:2023-11-30 09:50:12 24 4
gpt4 key购买 nike

我正在 cntk 中尝试一个简单的 lstm 网络,但出现以下错误:

RuntimeError                              Traceback (most recent call last)
<ipython-input-58-d0a0e4f580aa> in <module>()
6 trainer.train_minibatch({x: x1, l: y1})
7 if epoch % (EPOCHS / 10) == 0:
----> 8 training_loss = trainer.previous_minibatch_loss_average
9 loss_summary.append(training_loss)
10 print("epoch: {}, loss: {:.5f}".format(epoch, training_loss))

C:\Program Files\Anaconda3\envs\python2\lib\site-packages\cntk\train\trainer.pyc in previous_minibatch_loss_average(self)
285 The average training loss per sample for the last minibatch trained
286 '''
--> 287 return super(Trainer, self).previous_minibatch_loss_average()
288
289 @property

C:\Program Files\Anaconda3\envs\python2\lib\site-packages\cntk\cntk_py.pyc in previous_minibatch_loss_average(self)
2516
2517 def previous_minibatch_loss_average(self):
-> 2518 return _cntk_py.Trainer_previous_minibatch_loss_average(self)
2519
2520 def previous_minibatch_evaluation_average(self):

RuntimeError: There was no preceeding call to TrainMinibatch or the minibatch was empty.

[CALL STACK]
> CNTK::Trainer:: PreviousMinibatchLossAverage
- 00007FFFA932A5F6 (SymFromAddr() error: Attempt to access invalid address.)
- PyCFunction_Call
- PyEval_GetGlobals
- PyEval_EvalFrameEx
- PyEval_GetFuncDesc
- PyEval_GetGlobals
- PyEval_EvalFrameEx
- PyEval_EvalCodeEx
- PyFunction_SetClosure
- PyObject_Call (x2)
- PyObject_CallFunction
- PyObject_GenericGetAttrWithDict
- PyType_Lookup
- PyEval_EvalFrameEx

相关代码为:

# train
loss_summary = []
start = time.time()
for epoch in range(0, EPOCHS):
for x1, y1 in next_batch(x_train, y_train):
trainer.train_minibatch({x: x1, l: y1})
if epoch % (EPOCHS / 10) == 0:
training_loss = trainer.previous_minibatch_loss_average
loss_summary.append(training_loss)
print("epoch: {}, loss: {:.5f}".format(epoch, training_loss))

现在,我已经被困在这个问题上几个小时了,无法理解发生了什么。我正在关注 https://notebooks.azure.com/cntk/libraries/tutorials/html/CNTK_106A_LSTM_Timeseries_with_Simulated_Data.ipynb 上的教程并且搜索谷歌也没有帮助。

感谢您的帮助。

最佳答案

只是一个想法:您的 for(下一个小批量)循环是否可能永远不会执行?

我会尝试使用 pdb 来调试它。只需在 jupyter 单元顶部 import pdb 并在 for x1, y1 .. 循环之前添加 pdb.set_trace() 即可。运行单元格。您可以使用步骤 (s) 进入方法或使用下一步 (n) 继续。这也许可以帮助您分析跟踪,并且您可以使用 pdb 中的打印来证明变量。

关于python - CNTK运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46622363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com