Cosmetics.
authorFrancois Fleuret <francois@fleuret.org>
Thu, 12 Jan 2017 17:46:06 +0000 (18:46 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Thu, 12 Jan 2017 17:46:06 +0000 (18:46 +0100)
test-dagnn.lua

index 5b266da..1df04e2 100755 (executable)
 
 require 'torch'
 require 'nn'
 
 require 'torch'
 require 'nn'
-
 require 'dagnn'
 
 require 'dagnn'
 
+-- torch.setnumthreads(params.nbThreads)
+torch.setdefaulttensortype('torch.DoubleTensor')
+torch.manualSeed(2)
+
 function checkGrad(model, criterion, input, target)
    local params, gradParams = model:getParameters()
 
 function checkGrad(model, criterion, input, target)
    local params, gradParams = model:getParameters()
 
@@ -81,10 +84,6 @@ function printTensorTable(t)
    end
 end
 
    end
 end
 
--- torch.setnumthreads(params.nbThreads)
-torch.setdefaulttensortype('torch.DoubleTensor')
-torch.manualSeed(2)
-
 --                     +--> c ----> e --+
 --                    /            /     \
 --                   /            /       \
 --                     +--> c ----> e --+
 --                    /            /     \
 --                   /            /       \
@@ -93,12 +92,12 @@ torch.manualSeed(2)
 --                           \           /
 --                            +--> f ---+
 
 --                           \           /
 --                            +--> f ---+
 
-a = nn.Linear(10, 10)
+a = nn.Linear(50, 10)
 b = nn.ReLU()
 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()
 e = nn.CMulTable()
-f = nn.Linear(3, 3)
+f = nn.Linear(15, 15)
 g = nn.CAddTable()
 
 model = nn.DAG()
 g = nn.CAddTable()
 
 model = nn.DAG()
@@ -115,27 +114,8 @@ model:addEdge(f, g)
 model:setInput(a)
 model:setOutput(g)
 
 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()
 
 
 output:uniform()