# Feature maps in CNN and discriminative loss

**URL:** <https://discuss.pytorch.org/t/feature-maps-in-cnn-and-discriminative-loss/98847>\
**Category:** vision\
**Created:** [October 9, 2020, 10:16pm UTC](https://discuss.pytorch.org/t/feature-maps-in-cnn-and-discriminative-loss/98847 "2020-10-09T22:16:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hdk](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/h/ec9cab/32.png) [@Hdk](https://discuss.pytorch.org/u/Hdk)\
**Post date:** [October 9, 2020, 10:16pm UTC](https://discuss.pytorch.org/t/feature-maps-in-cnn-and-discriminative-loss/98847/1 "2020-10-09T22:16:31Z")

</div>

Suppose we have a CNN with five convolutional layers  
defined as (in\_features, out\_features, kernel, stride,padding) and no linear layers. Consider a dataset say Cifar10.

Conv1: (3, 32, 5, 1, 0)  
Conv2: (32, 64, 5, 1, 0)  
Conv3: (64, 128, 5, 1, 0)  
Conv4: (128, 256, 5, 1, 0)  
And output layer as convolutional layer itself.  
Conv5: (256, 10, \*, 1, 0)

1. Is it possible to get feature maps of one convolutional layer to be far different then its following convolutional layer? If so, how can we do it?

2. I want to calculate the loss of feature maps with respect to original image for each convolutional layer. And add it up to as usual cross entropy loss. i.e.

Loss1 = my\_Loss\_func (feature maps, images)  
Loss2 = torch.nn.CrossEntropyLoss(outputs,labels)  
loss = Loss1 + Loss2  
.  
loss.backward()  
…

But I think there’ll be error of size mismatch in Loss1 because now for 1 image we have feature maps= out\_features(say 32 if it’s conv1).

1. Does, the way I am defining Loss1, make it a discriminative loss? To be honest, I am not really sure about it. But I have to use discriminative loss, and I didn’t find much resources on how it can be implemented in context of feature maps.
