e-lab / torch-toolbox

A collection of snippets and libraries for Torch from e-Lab
https://engineering.purdue.edu/elab/
199 stars 64 forks source link

Usage with Native Torch #4

Closed robotsorcerer closed 8 years ago

robotsorcerer commented 8 years ago

Hi there,

How do you integrate this torch toolbox with a native installation of Torch?

Do you have a documentation or something related?

Cloning to my existing Torch installation directory seem to work well for me. But I get a compilation error:

/home/lex/torch/install/bin/luajit: farnnConv.lua:256: attempt to call a boolean value
stack traceback:
    farnnConv.lua:256: in main chunk
    [C]: in function 'dofile'
    .../lex/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406670

The code section in question is:

mlp        = nn.Sequential();  
input = 1    output = 1     HUs = 1;                   -- Hidden units in dynamic layer parameters
mlp:add(nn.Linear(input, HUs))              
mlp:add(nn.ReLU())                       
--mlp:add(nn.Linear(HUs, output))               
mlp:add(nn.SpatialConvolutionMM(3,4,5,5))

method = 'xavier'
mlp_x = require('weight-init')(mlp, method)

Thanks!

jhjin commented 8 years ago

@lakehanne Each module in the toolbox is meant to work without extra installation. For the weight initialization, all you need is to copy weight-init.lua into your working directory.

I've tested the code block to replicate the error but I could not. And the error msg does not seem to be related to the weight initialization module. One more comment is that using Linear with SpatialConvolutionMM will not work due to the dimension mismatch. You may want to take a look at nn.View module for changing the dimension.

robotsorcerer commented 8 years ago

I sent you an email. Please take a look at the code. Thanks!

jhjin commented 8 years ago

please let me know if you need more help

ghost commented 7 years ago

@jhjin Hi! I copy weight-init.lua from https://github.com/e-lab/torch-toolbox/blob/master/Weight-init/weight-init.lua into my work dictionary, but the error still exists. Could you help me if you know more reason? Thank you very much!!!

ghost commented 7 years ago

@jhjin My related code is: loadModel = false if loadModel ~= true then W = torch.load('c3d.t7') local method = 'xavier' model = require('weight-init')(model, method)