GoogleNet Visualize activation layer

vzmb: <p>I need Help to vizualice the layers activations on my Googlenet model, i need something like the following image:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/9/c92dc1c8a517bce9b9e370d58a6acb538f69782b.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/c92dc1c8a517bce9b9e370d58a6acb538f69782b" title="elephant_cam"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/9/c92dc1c8a517bce9b9e370d58a6acb538f69782b_2_690x460.jpeg" alt="elephant_cam" data-base62-sha1="sHI0kNLN20OzOBIO2Q6b5kdhwSf" width="690" height="460" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/9/c92dc1c8a517bce9b9e370d58a6acb538f69782b_2_690x460.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/c/9/c92dc1c8a517bce9b9e370d58a6acb538f69782b.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/c/9/c92dc1c8a517bce9b9e370d58a6acb538f69782b.jpeg 2x" data-dominant-color="8D9DAE"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">elephant_cam</span><span class="informations">899×600 210 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Honestly i don’t know what else can i do.</p>
<p>It is a pretrained model i only have 2 classes and it is a local dataset :</p>
<pre><code class="lang-auto">model = models.googlenet(pretrained=True)
</code></pre>
<pre><code class="lang-auto">loss_fn=nn.CrossEntropyLoss()
optimizer=optim.Adam(model.parameters(), lr=learning_rate)
</code></pre>
<p>this i how i train my model for training :</p>
<pre><code class="lang-auto">train_accu= []

train_losses=[]

def train(epoch):
  print('\nEpoch : %d'%epoch)
   
  model.train()
 
  running_loss=0
  correct=0
  total=0
 
  for batch_idx, (data, targets) in tqdm(enumerate(train_loader)):
     
    #inputs,labels=data[0].to(device),data[1].to(device)

    inputs = data.to(device=device,dtype=torch.float)
    labels = targets.to(device=device)
     
    optimizer.zero_grad()
    global outputs
    outputs=model(inputs)
    loss=loss_fn(outputs,labels)
    loss.backward()
    optimizer.step()
 
    running_loss += loss.item()
     
    _, predicted = outputs.max(1)
    total += labels.size(0)
    correct += (predicted == labels).sum().item()
       
  train_loss=running_loss/len(train_loader)
  accu=100.*correct/total
   
  train_accu.append(accu)
  train_losses.append(train_loss)
  print('Train Loss: %.3f | Accuracy: %.3f'%(train_loss,accu))
</code></pre>
<p>All the Layers:</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/3/e/3e36a9aa68a744630d19f13ded17785503032a41.png" alt="googlenet_table" data-base62-sha1="8SmIuoezTXHHWGpY49gCWo7lB5L" width="635" height="339"></p>
<p>and if you need more info here is the link of the model because i can not copy all the layer here, i do not have enough space</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://pytorch.org/hub/pytorch_vision_googlenet/">
  <header class="source">
      <img src="https://pytorch.org/favicon.ico?" class="site-icon" width="32" height="32">

      <a href="https://pytorch.org/hub/pytorch_vision_googlenet/" target="_blank" rel="noopener nofollow ugc">PyTorch</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/362;"><img src="https://pytorch.org/assets/images/social-share.jpg" class="thumbnail" width="690" height="362"></div>

<h3><a href="https://pytorch.org/hub/pytorch_vision_googlenet/" target="_blank" rel="noopener nofollow ugc">GoogLeNet</a></h3>

  <p>import torch
model = torch.hub.load('pytorch/vision:v0.10.0', 'googlenet', pretrained=True)
model.eval()</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>If anyone could help me I would really appreciate it a lot</p>

ptrblck: <p>Maybe <a href="https://github.com/utkuozbulak/pytorch-cnn-visualizations">this repository</a> could be useful in visualizing the class activations in the input image.</p>