Skip to content

Commit

Permalink
Merge pull request #40 from HyeongminMoon/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
L1aoXingyu authored Feb 11, 2022
2 parents 3c48d7e + db103d5 commit 61db1de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 08-AutoEncoder/conv_autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def forward(self, x):
criterion = nn.MSELoss()
optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate,
weight_decay=1e-5)
total_loss = 0

for epoch in range(num_epochs):
total_loss = 0
for data in dataloader:
img, _ = data
img = Variable(img).cuda()
Expand All @@ -76,8 +77,8 @@ def forward(self, x):
optimizer.zero_grad()
loss.backward()
optimizer.step()
total_loss += loss.data
# ===================log========================
total_loss += loss.data
print('epoch [{}/{}], loss:{:.4f}'
.format(epoch+1, num_epochs, total_loss))
if epoch % 10 == 0:
Expand Down

0 comments on commit 61db1de

Please sign in to comment.