Creating multiple Neural Networks on the fly (Lua, torch)

57 views
Skip to first unread message

aseem prashar

unread,
Dec 19, 2019, 6:40:06 PM12/19/19
to torch7
Hi everyone,
For the purpose of my thesis I wanna be able to create multiple Neural Networks with fixed confuguration(number of layers) on the fly.

I have tried eveyrthing but I am stuck on the following: creating a new and unique name for each NN.

Here is the method to create Neural Networks:

function CreateNN(self)
self = nn.Sequential()
self:add(nn.Reshape(1024))
self:add(nn.Linear(inputLayer, hiddenLayer1))
self:add(nn.ReLU())
self:add(nn.Linear(hiddenLayer1, hiddenLayer2))
self:add(nn.ReLU())
self:add(nn.Linear(hiddenLayer2, outputSize))
self:add(nn.LogSoftMax())

return self
end

Here is how I use it:

baseName=mlp
name1_G=mlpname..1
print(name1_G)  -- output: mlp1

name1_G=CreateNN()
print(mlp1) --output: nil


As you can see, the neural network is created for the name1_G and not mlp1 as intended. How do i overcome this?
Thank you!

Reply all
Reply to author
Forward
0 new messages