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

modified loss as per new pytorch version #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added pytorch/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion pytorch/nlp/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def evaluate(model, loss_fn, data_iterator, metrics, params, num_steps):
# compute all metrics on this batch
summary_batch = {metric: metrics[metric](output_batch, labels_batch)
for metric in metrics}
summary_batch['loss'] = loss.data[0]
summary_batch['loss'] = loss.item()
summ.append(summary_batch)

# compute mean of all metrics in summary
Expand Down
4 changes: 2 additions & 2 deletions pytorch/nlp/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def train(model, optimizer, loss_fn, data_iterator, metrics, params, num_steps):
# compute all metrics on this batch
summary_batch = {metric:metrics[metric](output_batch, labels_batch)
for metric in metrics}
summary_batch['loss'] = loss.data[0]
summary_batch['loss'] = loss.item()
summ.append(summary_batch)

# update the average loss
loss_avg.update(loss.data[0])
loss_avg.update(loss.item())
t.set_postfix(loss='{:05.3f}'.format(loss_avg()))

# compute mean of all metrics in summary
Expand Down
2 changes: 1 addition & 1 deletion pytorch/vision/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def evaluate(model, loss_fn, dataloader, metrics, params):
# compute all metrics on this batch
summary_batch = {metric: metrics[metric](output_batch, labels_batch)
for metric in metrics}
summary_batch['loss'] = loss.data[0]
summary_batch['loss'] = loss.item()
summ.append(summary_batch)

# compute mean of all metrics in summary
Expand Down
4 changes: 2 additions & 2 deletions pytorch/vision/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def train(model, optimizer, loss_fn, dataloader, metrics, params):
# compute all metrics on this batch
summary_batch = {metric:metrics[metric](output_batch, labels_batch)
for metric in metrics}
summary_batch['loss'] = loss.data[0]
summary_batch['loss'] = loss.item()
summ.append(summary_batch)

# update the average loss
loss_avg.update(loss.data[0])
loss_avg.update(loss.item())

t.set_postfix(loss='{:05.3f}'.format(loss_avg()))
t.update()
Expand Down