'Parameter tuning with data class?

I am trying to structure my code in order to optimise a CNN model. For this I need to vary learning rate and batch size. I was considering writing a class for these parameters using dataclass.

@dataclass
class Position:
    lr: List(float)
    batch_size: List(float)

I need to be to be able to pass lists of values:

lr = [0.01, 0.001],
batch_size = [20, 25]

For implementation of a CNN in pytorch, is this a good way to structure my code for optimisation? Could anyone recommend a better way if not?

These values will be varied in my training loop.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source