All zero output after pretrained VGG network's features

jangbi: <p>I am using the pretrained VGG network to implement Fast-RCNN. As mentioned in the paper, i divided the VGG into two parts, the feature and the classifier, Here’s my code.</p>
<pre><code class="lang-auto">def extract_vgg16(model):
    """
    First, the last max pooling layer is replaced by a RoI
    pooling layer that is configured by setting H and W to be
    compatible with the net’s first fully connected layer (e.g.,
    H = W = 7 for VGG16).
    
    Second, the network’s last fully connected layer and softmax
    (which were trained for 1000-way ImageNet classification)
    are replaced with the two sibling layers described
    earlier (a fully connected layer and softmax over K + 1 categories
    and category-specific bounding-box regressors).
    
    So this function returns the feature extractor from vgg but 
    removing the last max pooling layer.
    And the classifier removing the last fc layer
    :param model: 
    :return: 
    """
    features = list(model.features.children())
    features.pop()  # remove the last max pooling layer

    classifier = list(model.classifier.children())
    classifier.pop()  # remove the last fully connected layer and softmax

    return nn.Sequential(*features), nn.Sequential(*classifier)
</code></pre>
<p>And I use it like this:</p>
<pre><code class="lang-auto">    extractor, classifier = extract_vgg16(models.vgg16(pretrained=True))
    head = VGG16RoIHead(classifier, 3, (7, 7))
    model = FastRCNN(extractor, head)
</code></pre>
<p>However, when I check the output of the feature extractor, it turns to be all zero. Here’s the screenshots<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/7/72fa3a071e014a22f3b485d975e6bc6374c29677.png" data-download-href="https://discuss.pytorch.org/uploads/default/72fa3a071e014a22f3b485d975e6bc6374c29677" title="4"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/7/72fa3a071e014a22f3b485d975e6bc6374c29677_2_690x388.png" alt="4" data-base62-sha1="gp8xsZOCDF3Im6qN1RLxJrfQXAz" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/7/72fa3a071e014a22f3b485d975e6bc6374c29677_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/2X/7/72fa3a071e014a22f3b485d975e6bc6374c29677_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/7/72fa3a071e014a22f3b485d975e6bc6374c29677_2_1380x776.png 2x" data-dominant-color="333434"><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">4</span><span class="informations">1920×1080 121 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><br>
As you can see, the input tensor has no problem, but the feature extractor’s output seems to be strange.</p>

InnovArul: <p>Can you try to count the number of non-zero entries in the feature output?<br>
I have noticed the same sometime ago in VGGFace. The features are really sparse and this would be due to the ReLU unit. Nevertheless, the features (from VGGFace) are pretty good to use in Face recognition atleast.</p>
<p>I think, you need not worry about the nature of features unless they perform really poor in the task.</p>

jangbi: <p>Now I’ve found that the output of feature extractor is not all-zeros. But the RoIs’ output probs of classifer layer is all the same, even they represent total different area. I wonder if its my way to extract the pretrained VGG model has some problem?</p>

111103: <p>Hi, I find the same problem in my project, and how did you solve it?  Is there anything I should pay particular attention to, during extracting feas?</p>

jangbi: <p>Sorry, it’s been a long time since i deal with the code, i’ve almost forgot it all.</p>

Captan_levi: <p>Hi I am having the same problem, the output of pretrained vgg16 is mostly zeros.<br>
Further, its not too different of I feed some random numbers to it…</p>