victoresque / pytorch-template

PyTorch deep learning projects made easy.
MIT License
4.75k stars 1.09k forks source link

how can I add arg into config after data loading step #77

Closed Chunpai closed 3 years ago

Chunpai commented 4 years ago

I write a custom dataset and dataloader. The nn's input_dim is determined by one attribute of dataset. However, it seems I can only set the input_dim in config file. Any way to achieve this ? Thanks.

SunQpark commented 4 years ago

config.init_obj function (defined here) also accepts additional args, kwargs. So, I think you can use this on the train.py file, like

input_dim = data_loader.dataset.input_dim
model = config.init_obj('arch', module_arch, input_dim=input_dim)
Chunpai commented 4 years ago

config.init_obj function (defined here) also accepts additional args, kwargs. So, I think you can use this on the train.py file, like

input_dim = data_loader.dataset.input_dim
model = config.init_obj('arch', module_arch, input_dim=input_dim)

Thank you very much, @SunQpark .