Weighting different losses based on random initialization of network #13814
-
I'm working on a model with multiple losses that I add together: an autoencoder reconstruction loss (mse) and a prediction loss (cross entropy). I now want to weight them based on the Alternatively, I've also thought about creating a custom method in my model class that calculates the weights, stores them in self and then I would call that method manually after instantiating my model but prior to calling fit. Something like: class MyModelClass(pl.LightningModule):
def __init__(self):
...
def calculate_loss_weights(self):
# calculate my ratio
self.reconstruction_prediction_ratio = ratio
def training_step(self, loaders):
# all my training code
return self.reconstruction_prediction_ratio * reconstruction loss + prediction_loss
data = MyDataClass()
model = MyModelClass()
model.calculate_loss_weights()
trainer = pl.Trainer()
trainer.fit(model, data) However, I've realized that here too I don't know how to access my data loaders. Is there any way to implement this, and are there any best practices in terms of implementation I should stick to? Two things to note:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @Michael-Geuenich, I think #8114 will help. |
Beta Was this translation helpful? Give feedback.
Hi @Michael-Geuenich, I think #8114 will help.