2016-05-10 23 views

答えて

1

あなたは、Python/numpyのでLUA /トーチを埋めるためLutorpy、Pythonライブラリを試みることができます。ここで

は、変換の例を次に示します。詳細については

-- lua code        # python code (with lutorpy) 
--          import lutorpy as lua 
require "nn"     ===> require("nn") 
model = nn.Sequential()   ===> model = nn.Sequential() 
-- use ":" to access add  ===> # use "._" to access add 
model:add(nn.Linear(10, 3))  ===> model._add(nn.Linear(10, 3)) 
--          import numpy as np 
x = torch.Tensor(10):zero()  ===> arr = np.zeros(10) 
-- torch style(painful?)  ===> # numpy style(elegent?) 
x:narrow(1, 2, 6):fill(1)  ===> arr[1:7] = 1 
--          # convert numpy array to a torch tensor 
--          x = torch.fromNumpyArray(arr) 
--          # or you can still use torch style 
x:narrow(1, 7, 2):fill(2)  ===> x._narrow(1, 7, 2)._fill(2) 
-- 1-based index    ===> # 0-based index 
x[10] = 3      ===> x[9] = 3 
y = model:forward(x)   ===> y = model._forward(x) 
--          # you can convert y to a numpy array 
--          yArr = y.asNumpyArray() 

、あなたは可能性が後藤lutorpyのgithubのページ。

+1

深刻な使用には十分成熟していますか? – nn0p

関連する問題