Skip to content

Commit

Permalink
Remove duplicated logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rnett committed Dec 7, 2020
1 parent 93aba4d commit ff3cd6e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pytorch_lightning/utilities/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,12 @@ def lightning_get_attr_holder(model, attribute):

# Check if attribute in model.hparams, either namespace or dict
if hasattr(model, 'hparams'):
if isinstance(model.hparams, dict) and attribute in model.hparams:
return model.hparams
elif hasattr(model.hparams, attribute):
if attribute in model.hparams:
return model.hparams

# Check if the attribute in datamodule (datamodule gets registered in Trainer)
if trainer is not None and trainer.datamodule is not None and hasattr(trainer.datamodule, attribute):
if getattr(trainer.datamodule, attribute):
return trainer.datamodule
return trainer.datamodule

return None

Expand Down

0 comments on commit ff3cd6e

Please sign in to comment.