clementfarabet / torch-ios

Torch7 for iOS.
Other
196 stars 42 forks source link

Module 'nn' not found #31

Open 3DTOPO opened 7 years ago

3DTOPO commented 7 years ago

I am attempting to use a lua script that imports 'nn', but I get the error:

runTest.lua:1: module 'nn' not found:
    no field package.preload['nn']
    no file '/nn.lua'
    no file '/Users/jeshua/Library/Developer/CoreSimulator/Devices/F7864C0C-56E0-432C-A60E-E104C4A498DC/data/Containers/Bundle/Application/1F54279A-7B60-4192-A0A8-103AAE756AB1/TorchTest.app/framework/lua/nn.lua'
    no file './nn.lua'
    no file '//share/lua/5.1/nn.lua'
    no file '//share/lua/5.1/nn/init.lua'
    no file '//lib/lua/5.1/nn.lua'
    no file '//lib/lua/5.1/nn/init.lua'
    no file './nn.so'
    no file './nn.dylib'
    no file '//lib/lua/5.1/nn.so'
    no file '//lib/lua/5.1/nn.dylib'
    no file '//lib/lua/5.1/loadall.so//lib/lua/5.1/loadall.dylib'

I see there is already an nn folder in 3rd party, but I don't see any file called nn.lua or nn.dylib, etc. anywhere. Is it possible to use the 'nn' module?

ojalvotron commented 7 years ago

Have you tried to copy torch.framework (or the nn lua files) to the output target in XCode?

3DTOPO commented 7 years ago

Yes; the torch.framework is being copied. I followed this tutorial and this works:

if torch == nil then
  require "torch"
end

a = torch.rand(100,1)
b = torch.rand(1,100)
c = torch.dot(a,b)

print (c)
3DTOPO commented 7 years ago

Can someone show me an example how using nn is supposed to look like? This is how I am trying to use it:

if nn == nil then
   require "nn"
end

Should there be a nn.lua file or one of the files it is looking for above?

kurtjacobsdev commented 7 years ago

As far as I know you needn't import the nn package inside the lua script as it will already be loaded using the lua c api.

see: https://github.com/clementfarabet/torch-ios/blob/ios/ios_examples/XOR_Example/XOR_Example/xor_lua/main.lua

for an example.