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

Log epoch real time in LNNP #231

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions torchmdnet/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import torch
from torch.optim import AdamW
from torch.optim.lr_scheduler import ReduceLROnPlateau
from torch.nn.functional import local_response_norm, mse_loss, l1_loss
from torch.nn.functional import mse_loss, l1_loss
from torch import Tensor
from typing import Optional, Dict, Tuple

import time
from lightning import LightningModule
from torchmdnet.models.model import create_model, load_model

Expand Down Expand Up @@ -41,6 +41,8 @@ def __init__(self, hparams, prior_model=None, mean=None, std=None):
self.losses = None
self._reset_losses_dict()

self.tstart = time.time()

def configure_optimizers(self):
optimizer = AdamW(
self.model.parameters(),
Expand Down Expand Up @@ -222,6 +224,7 @@ def on_validation_epoch_end(self):
result_dict = {
"epoch": float(self.current_epoch),
"lr": self.trainer.optimizers[0].param_groups[0]["lr"],
"time": time.time() - self.tstart,
}
result_dict.update(self._get_mean_loss_dict_for_type("total"))
result_dict.update(self._get_mean_loss_dict_for_type("y"))
Expand All @@ -234,6 +237,7 @@ def on_test_epoch_end(self):
# Log all test losses
if not self.trainer.sanity_checking:
result_dict = {}
result_dict["time"] = time.time() - self.tstart
result_dict.update(self._get_mean_loss_dict_for_type("total"))
result_dict.update(self._get_mean_loss_dict_for_type("y"))
result_dict.update(self._get_mean_loss_dict_for_type("neg_dy"))
Expand Down
Loading