mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-05 16:36:44 +08:00
add code to forward prop before loss calculation
This commit is contained in:
@ -72,6 +72,7 @@ optimizer.step()
|
|||||||
# linear.bias.data.sub_(0.01 * linear.bias.grad.data)
|
# linear.bias.data.sub_(0.01 * linear.bias.grad.data)
|
||||||
|
|
||||||
# Print out the loss after optimization.
|
# Print out the loss after optimization.
|
||||||
|
pred = linear(x)
|
||||||
loss = criterion(pred, y)
|
loss = criterion(pred, y)
|
||||||
print('loss after 1 step optimization: ', loss.data[0])
|
print('loss after 1 step optimization: ', loss.data[0])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user