Hey there,
I am currently trying to set up a training pipeline. I am using config files for the parameters like:
data:
class_path: "vv.data.CIFAR10Loader"
init_args:
train_val_split: 0.8
seed: 42
batch_size: 1024
workers: 10
verbose: True
and
model:
class_path: "vv.models.Autoencoder"
init_args:
encoder:
class_path: "vv.models.Encoder"
init_args:
hidden_layer_sizes: [1000, 500, 300]
dropout_prob: 0.1
batch_norm: True
decoder:
class_path: "vv.models.Decoder"
init_args:
hidden_layer_sizes: [300, 500, 1000]
dropout_prob: 0.1
batch_norm: True
learning_rate: 0.001
i would like to link a property of my dataloader (data_size) that is created on instantiation to my model. In addition to the paramaters I provide in the config file for the model there also should be model.init_args.encoder.input_size and similar for the decoder. I would like these parameters to be infered from the data and I followed the Expert tutorial for extending the lighting CLI:
class CustomCLI(LightningCLI):
def add_arguments_to_parser(self, parser: LightningArgumentParser) -> None:
# Add early stopping as seperate argument
parser.add_lightning_class_args(EarlyStopping, "early_stopping")
parser.set_defaults({"early_stopping.monitor": "val_loss",
"early_stopping.patience": 5,
"early_stopping.verbose": False,
"early_stopping.mode": "min"})
# Link the image size to the layer size of the model
#print all class arguments of the parser
input("Press Enter to continue...")
parser.link_arguments("data.data_size",
"model.init_args.encoder.input_size",
apply_on="instantiate")
parser.link_arguments("data.data_size",
"model.init_args.decoder.output_size",
apply_on="instantiate")
Unfortunately my encoder never receives the data_size but instead gets “None” (I checked in the init method of my model). The tutorial does not specify anything further and I am unable to find anything in this regard online. Could you help me out?
best regards,
Nikita