How to get vectors after running model with test data? #12580
Replies: 4 comments 4 replies
-
Same issue as you. I noticed that the return value of But it seems that the |
Beta Was this translation helpful? Give feedback.
-
I figured out the problem with logging not working with testing. I didn't enable it! Once enabled logging of metrics works, however, logging of the vectors still only saves a single float. I have a workaround for now. I just save the vectors into the log directory separately and load them later for analysis. Here is the relevant modification:
Another issue with logging is that both during training and testing the logs are written to |
Beta Was this translation helpful? Give feedback.
-
to gather and return the predictions/outputs from LightningModule, consider using trainer.predict API. |
Beta Was this translation helpful? Give feedback.
-
My workaround (saving the CLS vectors during |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm using the Huggingface library for a text classification project. During testing, I would like access to the [CLS] vectors of the input. Currently, this is the code for my test steps inside my Lightning module:
This is how I run the test:
Now, the [CLS] vectors are correctly getting accumulated in
test_epoch_end
method. However, I don't know how to return them from there. I usedself.log
to log the vectors, however, this seems to log a single float value. Specficallyresult[0][cls]
is a single value instead of the (# samples, 768) dimension tensor. How would I return the [CLS] vectors after running through the test set?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions