Skip to content

Instantly share code, notes, and snippets.

@etrulls
Created August 17, 2017 16:33
Show Gist options
  • Save etrulls/f16fd249dc08949be60f6381b5a3e98e to your computer and use it in GitHub Desktop.
Save etrulls/f16fd249dc08949be60f6381b5a3e98e to your computer and use it in GitHub Desktop.
require 'nn'
require 'image'
desc = nn.Sequential()
desc:add( nn.SpatialConvolution( 1, 10, 3, 3, 1, 1 ) )
desc:add( nn.Tanh() )
desc:add( nn.SpatialLPPooling( 10, 2, 2, 2 ) )
desc:add( nn.SpatialSubtractiveNormalization( 10, image.gaussian(5) ) )
desc:add( nn.View( 10, -1 ) )
x1 = torch.randn(5, 1, 64, 64)
x2 = torch.randn(5, 1, 64, 64)
s = nn.Sequential()
t = nn.ParallelTable()
t:add(desc)
--t:add(desc:clone())
t:add(desc:clone('weight', 'bias', 'gradWeight', 'gradBias'))
s:add(t):add(nn.PairwiseDistance(2))
y = s:forward({x1, x2})
print(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment