Open
Conversation
sdesrozis
reviewed
Nov 29, 2021
| " loss1 = criterion(y_pred1, y1)\n", | ||
| " loss2 = criterion(y_pred2, y2)\n", | ||
| "\n", | ||
| " loss1.backward()\n", |
Contributor
There was a problem hiding this comment.
We talked about the tracking of each loss' components to figure out that x^2 can't be approximate by a Linear but 2*x can.
loss = loss1 + loss2
loss.backward()
return {"loss": loss.item(), "loss1": loss1.item(), "loss2": loss2.item()}
sdesrozis
reviewed
Nov 29, 2021
| " return self.model1(x), self.model2(x)\n", | ||
| "\n", | ||
| "model = Net().to(device)\n", | ||
| "optimizer = torch.optim.Adam(model.parameters(), lr=0.005)\n", |
Contributor
There was a problem hiding this comment.
Suggested change
| "optimizer = torch.optim.Adam(model.parameters(), lr=0.005)\n", | |
| "optimizer = torch.optim.Adam(model.parameters(), lr=0.1)\n", |
sdesrozis
reviewed
Nov 29, 2021
| "def log_validation_results(trainer):\n", | ||
| " val_evaluator.run(val_loader)\n", | ||
| " metrics = val_evaluator.state.metrics\n", | ||
| " print(f\"Validation Results - Epoch[{trainer.state.epoch}] Avg MAE: {metrics['mae']:.2f}\")" |
Contributor
There was a problem hiding this comment.
Add this to track losses
RunningAverage(output_transform=lambda x: x["loss"]).attach(trainer, "loss")
RunningAverage(output_transform=lambda x: x["loss1"]).attach(trainer, "loss1")
RunningAverage(output_transform=lambda x: x["loss2"]).attach(trainer, "loss2")
@trainer.on(Events.EPOCH_COMPLETED)
def iteration_results(trainer):
metrics = trainer.state.metrics
print(f"Iteration Results - Epoch[{trainer.state.iteration}] Metrics: {metrics}")
sdesrozis
reviewed
Nov 29, 2021
| "outputId": "edc26afc-fab2-44e2-9c39-fb99bf751396" | ||
| }, | ||
| "source": [ | ||
| "trainer.run(train_loader, max_epochs=1)" |
Contributor
There was a problem hiding this comment.
Suggested change
| "trainer.run(train_loader, max_epochs=1)" | |
| "trainer.run(train_loader, max_epochs=10)" |
Contributor
|
@Priyansi I left a few comments to track the losses. What do you think ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #68