Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only final layer .. #2

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions train.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ def cross_entropy_loss_RCF(prediction, label):
optim = make_optim(model, adjust_lr(init_lr, cnt, total_iter)) optim = make_optim(model, adjust_lr(init_lr, cnt, total_iter))
image, label = image.cuda(), label.cuda() image, label = image.cuda(), label.cuda()
outs = model(image, label.size()[2:]) outs = model(image, label.size()[2:])
total_loss = 0 # total_loss = 0
for each in outs: total_loss = cross_entropy_loss_RCF(outs[-1], label)
loss = cross_entropy_loss_RCF(each, label) # for each in outs:
total_loss += loss # loss = cross_entropy_loss_RCF(each, label)
# total_loss += loss
optim.zero_grad() optim.zero_grad()
total_loss.backward() total_loss.backward()
optim.step() optim.step()
Expand All @@ -85,5 +86,5 @@ def cross_entropy_loss_RCF(prediction, label):
avg_loss = 0 avg_loss = 0


if cnt % ckpt_cnt == 0: if cnt % ckpt_cnt == 0:
save_ckpt(model, 'lr-{}-iter-{}'.format(init_lr, cnt)) save_ckpt(model, 'only-final-lr-{}-iter-{}'.format(init_lr, cnt))