-
Notifications
You must be signed in to change notification settings - Fork 2.3k
How to get intermediate values of pretrained models? #2527
Comments
I have an experimental PR that does this: basically you can register a hook on the LSTM layer and use that hook to grab its output. that PR is still kind of half-baked, but it should point you in the right direction. |
If the model is your own code, then you can also change that to have hidden state in the |
However, what @joelgrus is suggesting is obviously cleaner, since that way you don't make hardcoded changes in model code just to tweak what predictor needs to give out at prediction time. |
Thanks for your replies @joelgrus @HarshTrivedi . I am also looking at using forward hooks to get intermediate values mainly from pretrained models. It works pretty well:) |
@snie2012 Hi, could you please specify how did you solve this issue? I am also looking for intermediate values of pertained model on new data. Thanks in advance! |
I have a new PR that's even cleaner, but it's not merged yet: https://github.com/allenai/allennlp/pull/2581/files |
@MeiqiGuo As @joelgrus says, use hooks can do the job. |
Closing since #2581 is merged. |
Is it possible to get the intermediate values of the hidden layers for the pretrained sequence tagging models when making prediction? For example, the output of the LSTM layer of a pretrained tagging model. If so, how?
The text was updated successfully, but these errors were encountered: