New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenFace Pre-Trained Model Incorrect DepthConcat #351

Closed
k22jung opened this Issue Mar 1, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@k22jung

k22jung commented Mar 1, 2018

Context of the issue.

The OpenFace pre-trained model nn4.small2.v1.t7 on your website may be trained incorrectly, or be outputting results that were not intended.

Expected behavior.

Inception 3a (and other Inception layers) should be outputting a tensor with W = 12 and H = 12, as outlined in your paper.

Actual behavior.

Printing out the output tensor size of Inception(3a) after a forward pass of nn4.small2.v1.t7:

nn.Inception    
   1
 256
  12
  12
[torch.LongStorage of size 4]

=============================================================================================    
nn.Sequential    
nn.SpatialConvolution    
   1
 128
  12
  12
[torch.LongStorage of size 4]



    
nn.Sequential    
nn.SpatialConvolution    
  1
 32
 12
 12
[torch.LongStorage of size 4]



    
nn.Sequential    
nn.SpatialMaxPooling    
  1
 32
  5
  5
[torch.LongStorage of size 4]



    
nn.Sequential    
nn.SpatialConvolution    
  1
 64
 12
 12
[torch.LongStorage of size 4]



    
=============================================================================================    

Where Sequential modules between the equal signs are concatenated by Inception(3a). We see that nn.SpatialMaxPooling has an output size of (1 x 32 x 5 x 5). Going into the Torch documentation and viewing the raw output, the DepthConcat layer used to make the Inception module actually adds padding to nn.SpatialMaxPooling to make it's dimensions W x H = 12 x 12. Here is the sample of the output I saw, from a forward pass of random images:

(1,188,.,.) = 
 Columns 1 to 9
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  5.6958  7.2319  6.6903  5.8021  5.1362  0.0000
  0.0000  0.0000  0.0000  1.5282  2.3826  2.2984  1.8731  1.6089  0.0000
  0.0000  0.0000  0.0000  2.0896  2.6127  2.3920  2.2793  2.7719  0.0000
  0.0000  0.0000  0.0000  1.6699  2.9239  2.4145  3.1898  2.7508  0.0000
  0.0000  0.0000  0.0000  1.6116  2.7840  1.8125  2.8891  2.4671  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000

Columns 10 to 12
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000
  0.0000  0.0000  0.0000


Steps to reproduce.

Script used to print out results:

#!/usr/bin/env th
require 'torch'
require 'nn'
require 'dpnn'

torch.setdefaulttensortype('torch.FloatTensor')

path = '/path/to/nn4.small2.v1.t7'
local net = torch.load(path):float()

net:evaluate()

local img = torch.randn(1, 1, 3, 96, 96)


net:forward(img[1])


function printOut (net)
    for i = 1, #net.modules do
		name = torch.type(net.modules[i])
		print(name)
		if name == "nn.Sequential" then
		  print(torch.type(net.modules[i].modules[1]))
		end

		print(net.modules[i].output:size())

		if name == "nn.Inception" then
		  print('=============================================================================================')
	      --printOut (net.modules[i].modules[1]) 
	      print(net.modules[i].output)
	      print('=============================================================================================')
		  do return end
		end
		print('\n\n')
		
	end
end

printOut(net)
  • Operating system: Ubuntu 16.04
  • Torch version: 7

bamos added a commit that referenced this issue Mar 2, 2018

@bamos bamos closed this Mar 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment