X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=dagnn.git;a=blobdiff_plain;f=test-dagnn.lua;h=b390a29a5b7b412c6ff019e44f51ef5ef5e2a6de;hp=cec37d246451b3eb7f639edbf946e22716d6d979;hb=HEAD;hpb=501034fda227664ac04ab5dd2d912f768bcd70e4 diff --git a/test-dagnn.lua b/test-dagnn.lua index cec37d2..b390a29 100755 --- a/test-dagnn.lua +++ b/test-dagnn.lua @@ -99,12 +99,17 @@ dag:connect(b, nn.Linear(10, 15), nn.ReLU(), d) dag:connect(c, d) dag:connect(c, e) +dag:setLabel(a, 'first module') + dag:setInput(a) dag:setOutput({ d, e }) --- Check the output of the dot file -print('Writing /tmp/graph.dot') -dag:saveDot('/tmp/graph.dot') +-- Check the output of the dot file. Generate a pdf with: +-- +-- dot ./graph.dot -Lg -T pdf -o ./graph.pdf +-- +print('Writing ./graph.dot') +dag:saveDot('./graph.dot') -- Let's make a model where the dag is inside another nn.Container. model = nn.Sequential() @@ -131,6 +136,8 @@ print('Gradient estimate error ' .. checkGrad(model, criterion, input, output, e -- Check that we can save and reload the model model:clearState() -torch.save('/tmp/test.t7', model) -local otherModel = torch.load('/tmp/test.t7') +torch.save('./test.t7', model) +local otherModel = torch.load('./test.t7') print('Gradient estimate error ' .. checkGrad(otherModel, criterion, input, output, epsilon)) + +dag:print()