Skip to content

OpenFace Pre-Trained Model Incorrect DepthConcat #351

@k22jung

Description

@k22jung

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions