Closed gonzalolc closed 8 years ago
Hello, you can adjust the feature length there. If you do this you may also have to update the model description there. Make note of the comments in the model description which are showing the shape of the activations at each layer. For a better understanding of this, check the Torch documentation for temporal convolutions.
Thank you. I'll start working based on this info
Hello @gheinrich and @lukeyeager . Thanks for your help I've been trying this model for my 64x64 image and when I run it in digits it gets stucked and does nothing. I have not modified the temporal convolution values, only the reshape and linear modules to fit the 4096 feature lenght. What can I do to fix it? Thanks
assert(pcall(function() require('dpnn') end), 'dpnn module required: luarocks install dpnn')
-- return function that returns network definition
return function(params)
-- get number of classes from external parameters (default to 14)
local nclasses = params.nclasses or 3
if pcall(function() require('cudnn') end) then
print('Using CuDNN backend')
backend = cudnn
convLayer = cudnn.SpatialConvolution
convLayerName = 'cudnn.SpatialConvolution'
else
print('Failed to load cudnn backend (is libcudnn.so in your library path?)')
if pcall(function() require('cunn') end) then
print('Falling back to legacy cunn backend')
else
print('Failed to load cunn backend (is CUDA installed?)')
print('Falling back to legacy nn backend')
end
backend = nn -- works with cunn or nn
convLayer = nn.SpatialConvolutionMM
convLayerName = 'nn.SpatialConvolutionMM'
end
local feature_len = 1
if params.inputShape then
assert(params.inputShape[1]==1, 'Network expects 1xHxW images')
params.inputShape:apply(function(x) feature_len=feature_len*x end)
end
local alphabet_len = 71 -- max index in input samples
local net = nn.Sequential()
-- feature_len x 1 x 1
net:add(nn.View(-1,feature_len))
-- feature_len
net:add(nn.OneHot(alphabet_len))
-- feature_len x alphabet_len
net:add(backend.TemporalConvolution(alphabet_len, 256, 7))
-- those shapes are assuming feature_len=4096
-- [4096-6=4090] x 256
net:add(nn.Threshold())
net:add(nn.TemporalMaxPooling(3, 3))
-- [(4090-3)/3+1=1363] x 256
net:add(backend.TemporalConvolution(256, 256, 7))
-- [1363-6=1357] x 256
net:add(nn.Threshold())
net:add(nn.TemporalMaxPooling(3, 3))
-- [(1357-3)/3+1=452] x 256
net:add(backend.TemporalConvolution(256, 256, 3))
-- [452-2=450] x 256
net:add(nn.Threshold())
net:add(backend.TemporalConvolution(256, 256, 3))
-- [450-2=448] x 256
net:add(nn.Threshold())
net:add(backend.TemporalConvolution(256, 256, 3))
-- [448-2=446] x 256
net:add(nn.Threshold())
net:add(backend.TemporalConvolution(256, 256, 3))
-- [446-2=444] x 256
net:add(nn.Threshold())
net:add(nn.TemporalMaxPooling(3, 3))
-- [(444-3)/3+1=148] x 256
net:add(nn.Reshape(37888))
-- 37888
net:add(nn.Linear(37888, 4096))
net:add(nn.Threshold())
net:add(nn.Dropout(0.5))
-- 4096
net:add(nn.Linear(4096, 4096))
net:add(nn.Threshold())
net:add(nn.Dropout(0.5))
-- 4096
net:add(nn.Linear(4096, nclasses))
net:add(backend.LogSoftMax())
-- weight initialization
local w,dw = net:getParameters()
w:normal():mul(5e-2)
return {
model = net,
loss = nn.ClassNLLCriterion(),
trainBatchSize = 128,
validationBatchSize = 128
}
end
Have you waited long enough? You can check the GPU utilization to see if the GPU is busy. If you train this model on CPU it is going to take forever...
Yes I waited long enough and yes I'm using a Nvidia getforce 950gtx. The problem is that digits just freezes and abort itself without an actual error
Closing due to inactivity. Let us know if you find a solution, thanks.
Hello I'm new in lua and i'm trying to input in the text-classification model a different image size since my dataset is not 1024 length. how can I do this Excuse me for my ignorance Thank you