Reputation: 13614
I use python for my real application and like to harness a torch model in python. Is there any available interface or a tenuous way to do so ?
Upvotes: 2
Views: 3805
Reputation: 164
There are several libraries enables you to interact with torch in python, but I would recommend lutorpy, here are some details:
lutorpy: the most promising one for deep learning with torch, it's based on lupa, easier to use(more pythonic). It keeps a lua engine in python, all lua variables and functions are automatically converted into python objects. So, you can import any torch module by using "require" function. You can easily convert almost any lua/torch code into python with very minimal change. It also provide conversion functions for numpy array and torch tensor,n the conversion is instant because they share the underlying memory.
lunatic-python: a minimal library for using lua in python, but the features are limited
lupa: a library for using lua in python with a lot of useful features, but it's for lua in general, not torch, for example you can't easily convert torch tensor into numpy array.
pytorch: a wrapper for torch, the code are taken from torch and compiled into python module, so you can use torch pythonicly, but the module you can use is very limited (only nn are supported so far).
Here is one example: https://stackoverflow.com/a/36896347/6262499
Upvotes: 5