Code Monkey home page Code Monkey logo

Comments (10)

mhmtsarigul avatar mhmtsarigul commented on July 17, 2024

You have 2 classes but you give 10 output from the logsoftmax.

from cvpr2015.

ilichev-andrey avatar ilichev-andrey commented on July 17, 2024

I changed the line net:add(nn.Linear(84, 10) to net:add(nn.Linear(84, 2), but the error remains.
Help. I'm new to this.

from cvpr2015.

mhmtsarigul avatar mhmtsarigul commented on July 17, 2024

Your batch size is very big. It could be the problem. Try with smaller batch.

from cvpr2015.

ilichev-andrey avatar ilichev-andrey commented on July 17, 2024

Does not work. could you help me with the correct data?
My goal is that the neural network can distinguish human from animal.

from cvpr2015.

mhmtsarigul avatar mhmtsarigul commented on July 17, 2024

net:add(nn.View(1699))

must be

net:add(nn.View(5184)).
for 181816.

I dont know what the problem is directly. It says something about batch size. Is this the full error message.

from cvpr2015.

ilichev-andrey avatar ilichev-andrey commented on July 17, 2024

New error!

nn.Sequential {
[input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> output]
(1): nn.SpatialConvolution(3 -> 6, 18x18)
(2): nn.ReLU
(3): nn.SpatialMaxPooling(2x2, 2,2)
(4): nn.SpatialConvolution(6 -> 16, 18x18)
(5): nn.ReLU
(6): nn.SpatialMaxPooling(2x2, 2,2)
(7): nn.View(5184)
(8): nn.Linear(5184 -> 120)
(9): nn.ReLU
(10): nn.Linear(120 -> 84)
(11): nn.ReLU
(12): nn.Linear(84 -> 2)
(13): nn.LogSoftMax
}
[0.0371s]
th> criterion = nn.ClassNLLCriterion()
[0.0761s]
th>
[0.0000s]
th> trainer = nn.StochasticGradient(net, criterion)
[0.0001s]
th> trainer.learningRate = 0.001
[0.0000s]
th> trainer.maxIteration = 5
[0.0000s]
th> trainer:train(trainset)

StochasticGradient: training

.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:67:
In 7 module of nn.Sequential:
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:47: input view (16x11x11) and desired view (5184) do not match
stack traceback:
[C]: in function 'error'
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:47: in function 'batchsize'
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:79: in function </root/facedetect/torch/install/share/lua/5.1/nn/View.lua:77>
[C]: in function 'xpcall'
.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
...facedetect/torch/install/share/lua/5.1/nn/Sequential.lua:44: in function 'forward'
...ct/torch/install/share/lua/5.1/nn/StochasticGradient.lua:35: in function 'train'
[string "_RESULT={trainer:train(trainset)}"]:1: in main chunk
[C]: in function 'xpcall'
/root/facedetect/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
...tect/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x004064f0

WARNING: If you see a stack trace below, it doesn't point to the place where this error occurred. Please use only the one above.
stack traceback:
[C]: in function 'error'
.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:67: in function 'rethrowErrors'
...facedetect/torch/install/share/lua/5.1/nn/Sequential.lua:44: in function 'forward'
...ct/torch/install/share/lua/5.1/nn/StochasticGradient.lua:35: in function 'train'
[string "_RESULT={trainer:train(trainset)}"]:1: in main chunk
[C]: in function 'xpcall'
/root/facedetect/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
...tect/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x004064f0
[0.3159s]


it looked at the beginning:
th> net:add(nn.View(16x9x9)) not "net:add(nn.View(1699))"
th> net:add(nn.Linear(16x9x9, 120)) not "net:add(nn.Linear(1699, 120))"

from cvpr2015.

mhmtsarigul avatar mhmtsarigul commented on July 17, 2024

Ok. 16 x 11 x 11 would be correct.

from cvpr2015.

ilichev-andrey avatar ilichev-andrey commented on July 17, 2024

I replaced it and did from the beginning:

th> net:add(nn.SpatialConvolution(3, 6, 9, 9))
th> net:add(nn.SpatialConvolution(6, 16, 9, 9))
th> net:add(nn.View(16x9x9))
th> net:add(nn.Linear(16x9x9, 120))

net = nn.Sequential()
net:add(nn.SpatialConvolution(3, 6, 11, 11))
net:add(nn.ReLU())
net:add(nn.SpatialMaxPooling(2,2,2,2))
net:add(nn.SpatialConvolution(6, 16, 11, 11))
net:add(nn.ReLU())
net:add(nn.SpatialMaxPooling(2,2,2,2))
net:add(nn.View(16x11x11))
net:add(nn.Linear(16x11x11, 120))
net:add(nn.ReLU())
net:add(nn.Linear(120, 84))
net:add(nn.ReLU())
net:add(nn.Linear(84, 2))
net:add(nn.LogSoftMax())

Error:
th> trainer:train(trainset)

StochasticGradient: training

.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:67:
In 7 module of nn.Sequential:
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:47: input view (16x16x16) and desired view (1936) do not match
stack traceback:
[C]: in function 'error'
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:47: in function 'batchsize'
/root/facedetect/torch/install/share/lua/5.1/nn/View.lua:79: in function </root/facedetect/torch/install/share/lua/5.1/nn/View.lua:77>
[C]: in function 'xpcall'
.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:63: in function 'rethrowErrors'
...facedetect/torch/install/share/lua/5.1/nn/Sequential.lua:44: in function 'forward'
...ct/torch/install/share/lua/5.1/nn/StochasticGradient.lua:35: in function 'train'
[string "_RESULT={trainer:train(trainset)}"]:1: in main chunk
[C]: in function 'xpcall'
/root/facedetect/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
...tect/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x004064f0

WARNING: If you see a stack trace below, it doesn't point to the place where this error occurred. Please use only the one above.
stack traceback:
[C]: in function 'error'
.../facedetect/torch/install/share/lua/5.1/nn/Container.lua:67: in function 'rethrowErrors'
...facedetect/torch/install/share/lua/5.1/nn/Sequential.lua:44: in function 'forward'
...ct/torch/install/share/lua/5.1/nn/StochasticGradient.lua:35: in function 'train'
[string "_RESULT={trainer:train(trainset)}"]:1: in main chunk
[C]: in function 'xpcall'
/root/facedetect/torch/install/share/lua/5.1/trepl/init.lua:661: in function 'repl'
...tect/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
[C]: at 0x004064f0


write 16x16x16
next error:
input view (16x12x12) and desired view (4096) do not match


maybe I'm not there to change the value?

from cvpr2015.

ilichev-andrey avatar ilichev-andrey commented on July 17, 2024

how to determine these parameters:

5x5 convolution kernel?
net:add(nn.SpatialConvolution(3, 6, 5, 5))

reshapes from a 3D tensor of 16x5x5 into 1D tensor of 1655?
net:add(nn.View(1655))

from cvpr2015.

mhmtsarigul avatar mhmtsarigul commented on July 17, 2024

Convolution makes your pictures smaller by m-1 n-1 where mxn is your filter. Subsampling makes a division over size. Your pictures are 96x96. 5x5 convolution will make them 92x92 if used without padding. Search about convolution and pooling.

from cvpr2015.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.