Skip to content

Commit cad2233

Browse files
committed
Fix logistic regression example
1 parent 182f862 commit cad2233

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

logreg/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_batch(batch_size=32):
5454

5555
# Reset gradients
5656
for param in fc.parameters():
57-
param.grad.zero_()
57+
param.grad.data.zero_()
5858

5959
# Forward pass
6060
output = l1(fc(batch_x), batch_y)
@@ -65,7 +65,7 @@ def get_batch(batch_size=32):
6565

6666
# Apply gradients
6767
for param in fc.parameters():
68-
param.data.add_(-1 * param.grad)
68+
param.data.add_(-1 * param.grad.data)
6969

7070
# Stop criterion
7171
if loss < 0.1:

0 commit comments

Comments
 (0)