from argparse import ArgumentParser
parser = ArgumentParser()
# Trainer arguments
parser.add_argument("--devices", type=int, default=2)
# Hyperparameters for the model
parser.add_argument("--layer_1_dim", type=int, default=128)
# Parse the user inputs and defaults (returns a argparse.Namespace)
args = parser.parse_args()
# Use the parsed arguments in your program
trainer = Trainer(devices=args.devices)
model = MyModel(layer_1_dim=args.layer_1_dim)
A lot of my arguments could be parsed through the command line to make it simpler to run multiple instances of the model.
E.g.:
Take inspiration from https://github.com/whwu95/ATM/
To build the arg parser for Torch Lightning: