0

A central requirement for the project I am working on is being able to read the activations of the neurons in the hidden layers of the PPO2 models that I trained using the Stable Baselines library. Here is a very related question. I would like to print them as demonstrated here. The closest I came to this is by doing this:

print(model.get_parameters())

This only prints the weights and biases but not the activations at prediction. I tried to edit the files of the Stable Baselines library but to no avail. I have also tried

print(model.policy)

and this returns <class 'stable_baselines.common.policies.MlpPolicy'> as this only refers to the type of policy I am using. If there is no way to do this effectively, would it be easy to migrate my simple environment and train with another library? Would appreciate any help/suggestions I can get.

1 Answers1

0

I think the easiest way, which does not require from you to override pytorch's methods, is to attach a forward hook. I think I found here the code exactly for your problem. However you still need to define a custom policy, where you paste all that hook attachment, but that should be not so hard in your case.

gehirndienst
  • 424
  • 2
  • 13