Skip to content

Commit 8256aee

Browse files
lwnealsoumith
authored andcommitted
Fix UserWarning in two examples (#293)
* Fix UserWarning This fixes the following warning in mnist/main.py src/torch_mnist.py:68: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument. Performance is unaffected. * Fix UserWarning in mnist_hogwild In this case, dim=1 because the input tensor x has ndim=2. See _get_softmax_dim in https://github.com/pytorch/pytorch/blob/master/torch/nn/functional.py
1 parent e11e079 commit 8256aee

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mnist/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def forward(self, x):
6565
x = F.relu(self.fc1(x))
6666
x = F.dropout(x, training=self.training)
6767
x = self.fc2(x)
68-
return F.log_softmax(x)
68+
return F.log_softmax(x, dim=1)
6969

7070
model = Net()
7171
if args.cuda:

mnist_hogwild/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def forward(self, x):
4242
x = F.relu(self.fc1(x))
4343
x = F.dropout(x, training=self.training)
4444
x = self.fc2(x)
45-
return F.log_softmax(x)
45+
return F.log_softmax(x, dim=1)
4646

4747
if __name__ == '__main__':
4848
args = parser.parse_args()

0 commit comments

Comments
 (0)