Repository navigation
Replies: 1 comment
|
One possible way is with forward hooks: import monai
import torch
net=monai.networks.nets.Densenet121(spatial_dims=2,in_channels=1,out_channels=1)
output_dict={}
def forward_hook(mod, inputs, outputs):
output_dict[mod]=outputs
def add_hooks(mod):
if isinstance(mod, monai.networks.nets.densenet._DenseLayer):
mod.register_forward_hook(forward_hook)
net.apply(add_hooks)
result=net(torch.rand(1,1,128,128))
print(output_dict)After the forward pass through the network |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello
I need to store the intermediate output of each dense block of monai densenet.
How can I do that?
All reactions