Using data from training_epoch_end in validation_epoch_end. #14491
-
I'm running a metric learning model, and I'd like to use embeddings from the training step for KNN lookups in the validation step. I tried to do so with the following code.
However, self.train_embeddings is either None, or uninitialized, when validation_epoch_end executes. Is there a way to communicate between these two methods, or send information from both to a final callback? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Just saw other answers explaining the order of train_epoch_end and val_epoch_end hooks. This issue was solved by moving any code needing both validation and training data to "on_train_epoch_end". |
Beta Was this translation helpful? Give feedback.
-
Do you perform KNN lookup also in "on_train_epoch_end"? |
Beta Was this translation helpful? Give feedback.
-
on_train_epoch_end function called 4 times when training ddp with 4 gpus. Each calls have 1/4 th of train and val embeddings seperately. Do you have any idea how to collect all embeddings together in order to perform knn lookup? |
Beta Was this translation helpful? Give feedback.
Just saw other answers explaining the order of train_epoch_end and val_epoch_end hooks. This issue was solved by moving any code needing both validation and training data to "on_train_epoch_end".