-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Adding non-layer param count to summary #17005
Merged
awaelchli
merged 32 commits into
Lightning-AI:master
from
rhiga2:feature/non_layer_model_summary
May 9, 2023
Merged
Adding non-layer param count to summary #17005
awaelchli
merged 32 commits into
Lightning-AI:master
from
rhiga2:feature/non_layer_model_summary
May 9, 2023
Conversation
This file contains 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
for more information, see https://pre-commit.ci
…ightning into feature/non_layer_model_summary
for more information, see https://pre-commit.ci
rhiga2
commented
Mar 9, 2023
…ightning into feature/non_layer_model_summary
for more information, see https://pre-commit.ci
rhiga2
requested review from
awaelchli,
carmocca,
justusschock and
williamFalcon
as code owners
March 9, 2023 20:31
awaelchli
added
feature
Is an improvement or enhancement
community
This PR is from the community
labels
Mar 10, 2023
Borda
approved these changes
Apr 18, 2023
justusschock
approved these changes
May 5, 2023
@rhiga2 Could you take a look at your implementation again for this case: import torch
from torch.utils.data import DataLoader, Dataset
from lightning.pytorch import LightningModule, Trainer
class RandomDataset(Dataset):
def __init__(self, size, length):
self.len = length
self.data = torch.randn(length, size)
def __getitem__(self, index):
return self.data[index]
def __len__(self):
return self.len
class BoringModel(LightningModule):
def __init__(self):
super().__init__()
self.layer = torch.nn.Linear(32, 2)
self.param = torch.nn.Parameter(torch.rand(3)) # this parameter is unused
def forward(self, x):
return self.layer(x)
def training_step(self, batch, batch_idx):
return self(batch).sum()
def train_dataloader(self):
return DataLoader(RandomDataset(32, 64), batch_size=2)
def configure_optimizers(self):
return torch.optim.SGD(self.layer.parameters(), lr=0.1)
def run():
model = BoringModel()
trainer = Trainer(max_steps=1)
trainer.fit(model)
if __name__ == "__main__":
run() which errors out with
|
awaelchli
reviewed
May 6, 2023
awaelchli
suggested changes
May 6, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall approach LGTM, but we are missing the regular use case when no example input array is provided. Let's extend the test case for that and handle the optional columns correctly.
…ightning into feature/non_layer_model_summary
for more information, see https://pre-commit.ci
…ightning into feature/non_layer_model_summary
for more information, see https://pre-commit.ci
awaelchli
reviewed
May 6, 2023
…ightning into feature/non_layer_model_summary
awaelchli
approved these changes
May 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
callback: model summary
community
This PR is from the community
feature
Is an improvement or enhancement
pl
Generic label for PyTorch Lightning package
ready
PRs ready to be merged
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.
What does this PR do?
This PR adds the count of parameters not associated to any layer to the model summary. The new model summary should add an extra row to the summary table that specifies the count of params that have not been reported by any layer summary.
Fixes #12736
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist