You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR adds Supervised Contrastive Replay (SCR). This is a draft implementation, open to discussion. The example is working in the sense that it runs without errors.
I have not used any online learning APIs so far.
Some caveats:
The accuracy cannot be measured at training time, since during training the SCR does not use any classifier (just a custom loss).
The SCR loss cannot be measured at test time since it requires building a multiviewed batch with augmentations. I switched to the CrossEntropy at eval time but people need to look at the APIDoc to know that. Also, I need to check if this switch may break something or if it is better to override self._criterion directly.
Transformations to build the multiviewed batch are supported only if they can work on (batched) tensors, not on single PIL images. This really simplifies the implementation. I think it could be feasible to remove this constraint, but we would probably need a custom dataset to apply transformations and augment the mini-batch.
The accuracy cannot be measured at training time, since during training the SCR does not use any classifier (just a custom loss).
I think this is not a problem, we are not really interested in the accuracy on the train stream (I mean, it's not a problem if we don't have it for free during training like what happens in supervised learning), but more on the validation stream. And I think this can be computed by using the nearest mean classifier on the buffer samples as they describe in the paper.
Yes, @AlbinSou I agree. I meant that if applied blindly, the user may expect to get the training accuracy and this would raise an error. But we cannot do much more than clarifying that in the APIdoc 😄
I agree with Albin, there are many other methods where you cannot compute the accuracy during training. Even better if it fails explicitly. Maybe add a comment in the doc.
Oh no! It seems there are some PEP8 errors! 😕
Don't worry, you can fix them! 💪
Here's a report about the errors and where you can find them:
avalanche/training/supervised/supervised_contrastive_replay.py:36:31: E251 unexpected spaces around keyword / parameter equals
avalanche/training/supervised/supervised_contrastive_replay.py:36:33: E251 unexpected spaces around keyword / parameter equals
avalanche/training/supervised/supervised_contrastive_replay.py:181:1: W391 blank line at end of file
2 E251 unexpected spaces around keyword / parameter equals
1 W391 blank line at end of file
Oh no! It seems there are some PEP8 errors! 😕
Don't worry, you can fix them! 💪
Here's a report about the errors and where you can find them:
avalanche/training/supervised/supervised_contrastive_replay.py:36:31: E251 unexpected spaces around keyword / parameter equals
avalanche/training/supervised/supervised_contrastive_replay.py:36:33: E251 unexpected spaces around keyword / parameter equals
avalanche/training/supervised/supervised_contrastive_replay.py:181:1: W391 blank line at end of file
2 E251 unexpected spaces around keyword / parameter equals
1 W391 blank line at end of file
@AntonioCarta I want to change the NCM Classifier because it is not very easy to use right now, but I will create a new PR for that, this can be merged if it looks ok for you
@AntonioCarta I want to change the NCM Classifier because it is not very easy to use right now, but I will create a new PR for that, this can be merged if it looks ok for you
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds Supervised Contrastive Replay (SCR). This is a draft implementation, open to discussion. The example is working in the sense that it runs without errors.
I have not used any online learning APIs so far.
Some caveats:
self._criterion
directly.