How to pass additional parameters to forward function during training and validation?

I use Ignite to train LSTM model based on this tutorial.

def forward(self, source, target, teacher_force_ratio=0.5):

How to pass target and teacher_force_ratio during training (teacher_force_ratio=0.5) and validation process (teacher_force_ratio=0)?

I have checked create_supervised_trainer and could not find such possibility.

Should I extend Dataset class:
return (source, target) -> return ((source, target, teacher_force_ratio), target)

1 Like

Hi @odats

You can create a trainer with a custom train_step (or update_fn) as here:
https://pytorch.org/ignite/concepts.html#engine

HTH

1 Like