sec*_*uaz 14 macos python-3.x deep-learning pytorch opennmt
I\xc2\xb4m 使用 Mac OS el capit\xc3\xa1n 并且我正在尝试遵循OpenNMT pytorch版本的快速入门教程。在训练步骤中,我收到以下警告消息:
\n\nOpenNMT-py/onmt/modules/GlobalAttention.py:177: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. \n\nalign_vectors = self.sm(align.view(batch*targetL, sourceL))\n/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/torch/nn/modules/container.py:67: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.\n input = module(input)\nRun Code Online (Sandbox Code Playgroud)\n\n第 1 步:预处理数据(按预期工作)
\n\npython preprocess.py -train_src data/src-train.txt -train_tgt data/tgt-train.txt -valid_src data/src-val.txt -valid_tgt data/tgt-val.txt -save_data data/demo\nRun Code Online (Sandbox Code Playgroud)\n\n第 2 步:训练模型(产生警告消息)
\n\npython train.py -data data/demo -save_model demo-model\nRun Code Online (Sandbox Code Playgroud)\n\n有没有人遇到过这个警告或者有任何解决办法?
\npro*_*sti 16
当您计算交叉熵时,几乎总是需要最后一个维度,因此您的线可能如下所示:
torch.nn.functional.log_softmax(x, -1)
Run Code Online (Sandbox Code Playgroud)
从警告中可以清楚地看出,您必须明确提及维度,因为 softmax 的隐式维度选择已被弃用。
就我而言,我正在使用log_softmax并更改了下面的代码行以包含尺寸。
torch.nn.functional.log_softmax(x) # This throws warning.
Run Code Online (Sandbox Code Playgroud)
更改为
torch.nn.functional.log_softmax(x, dim = 1) # This doesn't throw warning.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20450 次 |
| 最近记录: |