Base strategy adaptation for revisiting the exact same data with self.batches #451
Unanswered
Mattdl
asked this question in
Feature Request
Replies: 1 comment 2 replies
-
If I understand correctly your problem, you may be able to solve it by modifying also the I will work on this (#452). |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm trying to finetune an independent model within a strategy on the exact same data as seen for the current batch.
However, the losses for this model I want to add to the loss of the model being optimized currently in the base strategy.
In practice, this proves difficult as before/after_forward happen before the calculating the loss fo the current network. But after
loss+=criterion(...)
for the current task I would like to process the loss for the independently finetuned model, so I can just add to the loss as well within the strategy.What I tried now is to implement it in the before_backward, and to iterate over the exact same data:
def before_backward(self, strategy, **kwargs): for mb_task_id, (mb_x, mb_y) in strategy.current_dataloader[strategy.mb_it].items(): .... # Process
However, I get an error because I can't index the dataloader. I think this would be solved if there was a self.batches in the base strategy which allows to easily iterate over the batches again.
This would allow to:
def before_backward(self, strategy, **kwargs): for mb_task_id, (mb_x, mb_y) in self.batches.items(): .... # Process
Beta Was this translation helpful? Give feedback.
All reactions