Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua -> python translation failed #41

Open
jsqihui opened this issue Feb 13, 2017 · 4 comments
Open

lua -> python translation failed #41

jsqihui opened this issue Feb 13, 2017 · 4 comments

Comments

@jsqihui
Copy link

jsqihui commented Feb 13, 2017

lua file works fine

require "torch"
require "nn"
require "nngraph"
require "optim"
package.path = '/root/runtime/SROM/srom_torch_model.lua;' .. package.path
require "srom_torch_model"

model = Torch_model.new('./')
print(model)

python3 file doesn't work

import lutorpy as lua
require("torch")
require("nn")
require("nngraph")
require("optim")
package.path = '/root/runtime/SROM/srom_torch_model.lua;' + package.path
require("srom_torch_model")

model = Torch_model.new("./")
print(model)

Throws the error:
File "test.py", line 9, in
model = Torch_model.new("./")
NameError: name 'Torch_model' is not defined

Any idea about this? The srom_torch_model is a customized lua model. Thanks

@oeway
Copy link
Collaborator

oeway commented Feb 14, 2017

Could you show some snippet to see how Torch_model is defined?

@jsqihui
Copy link
Author

jsqihui commented Feb 14, 2017

require 'torch'
Torch_model = torch.class('Torch_model')

@oeway I believe I found the problem.I guess it is because lutorpy for python3 doesn't support package.path very well. I also leave some comments here: #4 I use the work around to setup LUA_PATH in bashrc directly to get the problem solved(no need to modify the package.path anymore)

@oeway
Copy link
Collaborator

oeway commented Feb 14, 2017

Thanks for the clarification, but I have no idea right now. I remember that that kind of code worked in python2, is it possible for you to try with python2?

@jsqihui
Copy link
Author

jsqihui commented Feb 14, 2017

It works fine with python2, but some outside call in my case need python3, I have to stick with python3. I will use the work around by setting LUA_PATH. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants