How to prepare data for torch7 deep learning convolutional neural network example?

751 views Asked by At

I have been trying to use convolutional neural network example in deep learning library of torch7(convolutionalneuralnetwork.lua) for my own dataset. I have a dataset of 100x100 binary jpg images and they are in the following directories:
/home/akshay/project/data/train -- training data
/home/akshay/project/data/valid -- validation data

I have changed the dataset to ImageSource and made the other necessary changes as in the code:

cmd:option('--dataset', 'ImageSource', 'which dataset to use : Mnist | NotMnist | Cifar10 | Cifar100 | Svhn | ImageSource')
cmd:option('--trainPath', paths.concat(dp.DATA_DIR, '/home/akshay/project/data/train'), 'Where to look for training images')
cmd:option('--validPath', paths.concat(dp.DATA_DIR, '/home/akshay/project/data/valid'), 'Where to look for validation images')
cmd:option('--metaPath', paths.concat(dp.DATA_DIR, '/home/akshay/project/data/meta'), 'Where to cache meta data')
cmd:option('--loadSize', '{1, 100, 100}', 'Image size')
cmd:option('--sampleSize', '{1, 100, 100}', 'The size to use for cropped images')

But when I ran the code, I got an error as below:

/usr/local/bin/luajit: /usr/local/share/lua/5.1/dp/data/imagesource.lua:49: attempt to perform arithmetic on a nil value
stack traceback:
/usr/local/share/lua/5.1/dp/data/imagesource.lua:49: in function '__init'
/usr/local/share/lua/5.1/torch/init.lua:54: in function </usr/local/share/lua/5.1/torch/init.lua:50>
[C]: in function 'ImageSource'
convnet.lua:90: in main chunk
[C]: in function 'dofile'
/usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk
[C]: at 0x0804d350

1).How do I prepare the data differently?
2).Are the parameters passed wrong and How to correct them?

1

There are 1 answers

0
Akanksha Gupta On

I was getting the same error. Change your --loadSize to be '1,100,100' instead of '{1,100,100}'. Similarly for --sampleSize.