You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+28
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,34 @@ Using **ForwardHookManager**, you can extract intermediate representations in mo
34
34
[This example notebook](https://github.com/yoshitomo-matsubara/torchdistill/tree/main/demo/extract_intermediate_representations.ipynb)[](https://colab.research.google.com/github/yoshitomo-matsubara/torchdistill/blob/main/demo/extract_intermediate_representations.ipynb)[](https://studiolab.sagemaker.aws/import/github/yoshitomo-matsubara/torchdistill/blob/main/demo/extract_intermediate_representations.ipynb)
35
35
will give you a better idea of the usage such as knowledge distillation and analysis of intermediate representations.
36
36
37
+
E.g., extract intermediate representations (feature map) of ResNet-18 for a random input batch
38
+
```python
39
+
import torch
40
+
from torchvision import models
41
+
from torchdistill.core.forward_hook import ForwardHookManager
42
+
43
+
# Define a model and choose torch device
44
+
model = models.resnet18(pretrained=False)
45
+
device = torch.device('cpu')
46
+
47
+
# Register forward hooks for modules of your interest
0 commit comments