Closed mzweilin closed 2 months ago
I thought we could use the
DotDict
to access things within adict
?
Good point. We can enhance the capability of mart.nn.Get()
using DotDict
, in case a model returns a multi-level dicts that hide loss in depth. But I don't think we can directly use DotDict
as gain_fn
:
What does this PR do?
This PR adds
mart.nn.Get(key)
to get a value from**kwargs
by key.One use case is when
model.training_step()
returns a dictionary with the loss value, we can usemart.nn.Get(key)
to fetch the loss in the Gain function.Type of change
Please check all relevant options.
Testing
Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.
pytest
CUDA_VISIBLE_DEVICES=0 python -m mart experiment=CIFAR10_CNN_Adv trainer=gpu trainer.precision=16
reports 70% (21 sec/epoch).CUDA_VISIBLE_DEVICES=0,1 python -m mart experiment=CIFAR10_CNN_Adv trainer=ddp trainer.precision=16 trainer.devices=2 model.optimizer.lr=0.2 trainer.max_steps=2925 datamodule.ims_per_batch=256 datamodule.world_size=2
reports 70% (14 sec/epoch).Before submitting
pre-commit run -a
command without errorsDid you have fun?
Make sure you had fun coding 🙃