You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/adrian/.conda/envs/lightning/lib/python3.7/site-packages/torch/multiprocessing/spawn.py", line 20, in _wrap
fn(i, *args)
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/accelerators/ddp_spawn_accelerator.py", line 145, in ddp_train
self.trainer.train_loop.setup_training(model)
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/trainer/training_loop.py", line 135, in setup_training
self.trainer.logger.log_hyperparams(ref_model.hparams_initial)
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/utilities/distributed.py", line 35, in wrapped_fn
return fn(*args, **kwargs)
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/loggers/wandb.py", line 138, in log_hyperparams
params = self._sanitize_callable_params(params)
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/loggers/base.py", line 194, in _sanitize_callable_params
return {key: _sanitize_callable(val) forkey, valinparams.items()}
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/loggers/base.py", line 194, in<dictcomp>return {key: _sanitize_callable(val) forkey, valinparams.items()}
File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/loggers/base.py", line 191, in _sanitize_callable
return val.__name__
File "/home/adrian/.conda/envs/lightning/lib/python3.7/site-packages/torch/nn/modules/module.py", line 772, in __getattr__
type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'Backbone' object has no attribute '__name__'
awaelchli
changed the title
WandbLogger throws AttributeError in _sanitize_callable_params function
WandbLogger _sanitize_callable_params throws AttributeError if param does not have __name__
Oct 26, 2020
def test_wandb_sanitize_callable_params_with_model(tmpdir):
"""
Callback function are not serializiable. Therefore, we get them a chance to return
something and if the returned type is not accepted, return None.
"""
class ExtendedModel(BoringModel):
@staticmethod
def add_model_specific_args(parser):
parser = ArgumentParser(parents=[parser], add_help=False)
parser.add_argument('--learning_rate', type=float, default=0.0001)
return parser
parser = ArgumentParser()
parser.add_argument('--batch_size', default=32, type=int)
parser.add_argument('--hidden_dim', type=int, default=128)
parser = Trainer.add_argparse_args(parser)
parser = ExtendedModel.add_model_specific_args(parser)
args = parser.parse_args('--max_steps 1'.split(' '))
model = ExtendedModel()
logger = WandbLogger(project="test", name="test", offline=True)
# ------------
trainer = Trainer.from_argparse_args(args, max_steps=1, limit_train_batches=2, logger=logger)
trainer.fit(model)
I created this code to reproduce the bug, but I couldn't. I have removed the name by default which None
🐛 Bug
Using WandB logger throws an error:
To Reproduce
Expected behavior
Environment
environment does not matter
Additional context
A recent PR #4320 introduced the function that throws the error.
cc @tchaton
The text was updated successfully, but these errors were encountered: