require 'torch'
require 'nn'
-
require 'dagnn'
+-- torch.setnumthreads(params.nbThreads)
+torch.setdefaulttensortype('torch.DoubleTensor')
+torch.manualSeed(2)
+
function checkGrad(model, criterion, input, target)
local params, gradParams = model:getParameters()
end
end
--- torch.setnumthreads(params.nbThreads)
-torch.setdefaulttensortype('torch.DoubleTensor')
-torch.manualSeed(2)
-
-- +--> c ----> e --+
-- / / \
-- / / \
-- \ /
-- +--> f ---+
-a = nn.Linear(10, 10)
+a = nn.Linear(50, 10)
b = nn.ReLU()
-c = nn.Linear(10, 3)
-d = nn.Linear(10, 3)
+c = nn.Linear(10, 15)
+d = nn.Linear(10, 15)
e = nn.CMulTable()
-f = nn.Linear(3, 3)
+f = nn.Linear(15, 15)
g = nn.CAddTable()
model = nn.DAG()
model:setInput(a)
model:setOutput(g)
-input = torch.Tensor(3, 10):uniform()
-
-print('******************************************************************')
-print('** updateOutput **************************************************')
-print('******************************************************************')
-
-output = model:updateOutput(input):clone()
-
-printTensorTable(output)
-
-print('******************************************************************')
-print('** updateGradInput ***********************************************')
-print('******************************************************************')
-
-gradInput = model:updateGradInput(input, output)
-
-printTensorTable(gradInput)
-
-print('******************************************************************')
-print('** checkGrad *****************************************************')
-print('******************************************************************')
+local input = torch.Tensor(30, 50):uniform()
+local output = model:updateOutput(input):clone()
output:uniform()