Torch (machine learning)
Torch is an open-source machine learning library, a scientific computing framework, and a scripting language based on Lua.[3] It provides LuaJIT interfaces to deep learning algorithms implemented in C. It was created by the Idiap Research Institute at EPFL. Torch development moved in 2017 to PyTorch, a port of the library to Python.[4][5][6] torchThe core package of Torch is The following exemplifies using torch via its REPL interpreter: > a = torch.randn(3, 4)
> =a
-0.2381 -0.3401 -1.7844 -0.2615
0.1411 1.6249 0.1708 0.8299
-1.0434 2.2291 1.0525 0.8465
[torch.DoubleTensor of dimension 3x4]
> a[1][2]
-0.34010116549482
> a:narrow(1,1,2)
-0.2381 -0.3401 -1.7844 -0.2615
0.1411 1.6249 0.1708 0.8299
[torch.DoubleTensor of dimension 2x4]
> a:index(1, torch.LongTensor{1,2})
-0.2381 -0.3401 -1.7844 -0.2615
0.1411 1.6249 0.1708 0.8299
[torch.DoubleTensor of dimension 2x4]
> a:min()
-1.7844365427828
The Objects created with the torch factory can also be serialized, as long as they do not contain references to objects that cannot be serialized, such as Lua coroutines, and Lua userdata. However, userdata can be serialized if it is wrapped by a table (or metatable) that provides nnThe > mlp = nn.Sequential()
> mlp:add(nn.Linear(10, 25)) -- 10 input, 25 hidden units
> mlp:add(nn.Tanh()) -- some hyperbolic tangent transfer function
> mlp:add(nn.Linear(25, 1)) -- 1 output
> =mlp:forward(torch.randn(10))
-0.1815
[torch.Tensor of dimension 1]
Loss functions are implemented as sub-classes of function gradUpdate(mlp, x, y, learningRate)
local criterion = nn.ClassNLLCriterion()
local pred = mlp:forward(x)
local err = criterion:forward(pred, y);
mlp:zeroGradParameters();
local t = criterion:backward(pred, y);
mlp:backward(x, t);
mlp:updateParameters(learningRate);
end
It also has Other packagesMany packages other than the above official packages are used with Torch. These are listed in the torch cheatsheet.[7] These extra packages provide a wide range of utilities such as parallelism, asynchronous input/output, image processing, and so on. They can be installed with LuaRocks, the Lua package manager which is also included with the Torch distribution. ApplicationsTorch is used by the Facebook AI Research Group,[8] IBM,[9] Yandex[10] and the Idiap Research Institute.[11] Torch has been extended for use on Android[12][better source needed] and iOS.[13][better source needed] It has been used to build hardware implementations for data flows like those found in neural networks.[14] Facebook has released a set of extension modules as open source software.[15] See alsoReferences
External links |