In [1]:
require 'nn';

In [2]:
inp = torch.Tensor{{4,5,2,2,1},{3,3,2,2,4},{4,3,4,1,1},{5,1,4,1,2},{5,1,3,1,4}}

In [3]:
mod = nn.SpatialConvolution(1,1,3,3)

In [4]:
mod.weight[{{1,1}}] = torch.Tensor{{4,3,3},{5,5,5},{2,4,3}}

In [5]:
mod.bias = torch.Tensor{0}

In [7]:
inp = inp:reshape(1,5,5)

In [8]:
mod:forward(inp:reshape(1,5,5))


Out[8]:
(1,.,.) = 
  109   92   72
  108   85   74
  110   74   79
[torch.DoubleTensor of size 1x3x3]


In [9]:
mod:backward(inp:reshape(1,5,5),torch.ones(1,3,3))


Out[9]:
(1,.,.) = 
   4   7  10   6   3
   9  17  25  16   8
  11  23  34  23  11
   7  16  24  17   8
   2   6   9   7   3
[torch.DoubleTensor of size 1x5x5]


In [ ]: