I have been trying to visualize the outputs of a vgg.16 network. But the output seems to be just wrong. As you know the convoltuion doesnt translate the semantic segment of the picture . like for the folwing picture if the head is on the top part of the picture it should be on top of the picture still after the convolution is done . But it doesnt seem to be the case . I used the following code to extract the intermediate layers .
class vgg16(torch.nn.Module): def __init__(self, pretrained=True): super(vgg16, self).__init__() vgg_pretrained_features = tv.vgg16(pretrained=pretrained).features self.layerss = torch.nn.Sequential() for x in range(30): self.layerss.add_module(str(x), vgg_pretrained_features[x]) self.layerss.eval() def forward(self, x): output= for i,layer in enumerate( self.layerss): # print (i) x=layer(x) output.append(x) return output model=vgg16() output=model.forward(img) import matplotlib.pyplot as plt plt.imshow(output.detach())
here is the original picture and the ouput of the first chanel of the first layer in vgg:
As you can see the face has moved all the way down and the neckless is all the way up and the overal structure of the picture is broken