python-3.x - 用户警告 : Implicit dimension choice for log_softmax has been deprecated

标签 python-3.x macos deep-learning pytorch opennmt

我正在使用 Mac OS el capitán 并且我正在尝试遵循 quick start tutorial for OpenNMT pytorch 版本。在训练步骤中,我收到以下警告消息:

OpenNMT-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. 

align_vectors = self.sm(align.view(batch*targetL, sourceL))
/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.
  input = module(input)

第 1 步:预处理数据(按预期工作)
python 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

第 2 步:训练模型(产生警告消息)
python train.py -data data/demo -save_model demo-model

有没有人遇到过这个警告或有任何解决方法?

最佳答案

从警告中可以清楚地看出,您必须明确提及维度,因为 softmax 的隐式维度选择已被弃用。

就我而言,我使用的是 log_softmax 并且我已经更改了下面的代码行以包含维度。

torch.nn.functional.log_softmax(x) # This throws warning.

改为
torch.nn.functional.log_softmax(x, dim = 1) # This doesn't throw warning.

关于python-3.x - 用户警告 : Implicit dimension choice for log_softmax has been deprecated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49006773/

相关文章:

python - 值错误 : You are trying to load a weight file containing 6 layers into a model with 0

python-3.x - 从原始列表中查找列表中所有缺失的元素

python - 将值从一个 python 脚本返回到另一个

objective-c - NSDateFormatter 不会使用区域设置解析日期?

java - 如何将我的 JMenuBar 移动到 Mac OS X 上的屏幕菜单栏?

c++ - dnn 模块的权重和偏差的内存布局是什么?

python - 提高连体网络的准确性

python - "import tensorflow as tf"导入错误 : Could not find 'cudart64_90.dll'

python - 从 Python 2 返回的区别——版本检查和 Python 3

cocoa - 具有多个存储的核心数据存储原子性