Closed johnyboyoh closed 9 years ago
In model definition, you need to use SpatialConvolution instead of SpatialConvolutionMap, with appropriate padding. AFAIK SpatialConvolutionMap does not have CUDA support. So I use this
batchSize = params.batchSize or 1
local padw, padh = torch.floor(params.kernelsize/2.0), torch.floor(params.kernelsize/2.0)
encoder:add(nn.SpatialConvolution(inputFeatures,outputFeatures, kw, kh, 1, 1, padw, padh))
and then use the same padding for the decoder:
decoder = unsupgpu.SpatialConvFistaL1(decodertable, kw, kh, iw, ih, padw, padh, params.lambda, batchSize)
I have tested the code with different input size using this and it worked. Let me know if this works for you.
@viorik Thanks. This solved this issue for me!
@viorik I was able to install the package (added installation instructions to the Wiki) and I am now trying to test it on a simple example, which is an adaptation of this example: https://github.com/torch/demos/blob/master/train-autoencoder/train-autoencoder.lua to work with the mnist dataset (32x32 image patches and 9x9 conv kernel).
I tested my code with unsup and it works OK. Trying to port to unsupgpu I made some minor changes. Instead of using: decoder = unsup.SpatialConvFistaL1(decodertable, kw, kh, iw, ih, params.lambda) I am now using: decoder = unsupgpu.SpatialConvFistaL1(decodertable, kw, kh, iw, ih, 0, 0, params.lambda,params.batchsize) with 0,0 being the padding parameters. I also tried changing this to 4,4 to 2,2 and to 1,1. All result in an inconsistent tensor size error upon calling: module:updateOutput(input, target)
using 0,0 results in the following error:
.../torch/install/share/lua/5.1/nn/WeightedMSECriterion.lua:10: inconsistent tensor size at /tmp/luarocks_torch-scm-1-7398/torch7/lib/TH/generic/THTensorCopy.c:7 stack traceback: [C]: in function 'copy' .../torch/install/share/lua/5.1/nn/WeightedMSECriterion.lua:10: in function 'updateOutput' /home/torch/install/share/lua/5.1/unsupgpu/FistaL1.lua:51: in function 'f' /home/torch/install/share/lua/5.1/optim/fista.lua:78: in function 'FistaLS' /home/torch/install/share/lua/5.1/unsupgpu/FistaL1.lua:119: in function 'updateOutput' /home/torch/install/share/lua/5.1/unsupgpu/psd.lua:52: in function 'updateOutput' train-autoencoder-mnist.lua:271: in main chunk
using 4,4 results in the following error:
/home/torch/install/share/lua/5.1/unsupgpu/FistaL1.lua:116: inconsistent tensor size at /tmp/luarocks_torch-scm-1-7398/torch7/lib/TH/generic/THTensorCopy.c:7 stack traceback: [C]: in function 'copy' /home/torch/install/share/lua/5.1/unsupgpu/FistaL1.lua:116: in function 'updateOutput' /home/torch/install/share/lua/5.1/unsupgpu/psd.lua:52: in function 'updateOutput' train-autoencoder-mnist.lua:271: in main chunk
here's the main file code: