文章介绍从一门新的语言 Lua 学习深度学习 Deep Learning。 整体流程:在一种轻量级的脚本语言 Lua 和高效解释器 LuaJIT 的支持下,实现了用于科学计算的 Torch 库, 除此之外,提供了更多用于深度学习的扩展,比如 nn、cutorch、cunn 和 cudnn。
What is Lua
Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
What is LuaJIT
Lua 是一种脚本语言,Lua 语言官方提供了其执行需要的解译器,如果要更高效执行, 则使用 LuaJIT。
It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler.
正如 Python 是一种语言, 定义了语言规范, 解释器可以有不同的实现方式, 如 CPython、Jython。
What is Torch
Torch is a scientific computing framework with wide support for machine learning algorithms that puts GPUs first. It is easy to use and efficient, thanks to an easy and fast scripting language, LuaJIT, and an underlying C/CUDA implementation.
More Packages
学习深度学习,需要一些额外库的支持,下面罗列一些常用的。
- nn: provides an easy and modular way to build and train simple or complex neural networks using Torch.
- cutorch: Cutorch provides a CUDA backend for torch7.
- cunn:provides a CUDA implementation for many of the modules in the base nn package.
- cudnn: Torch7 FFI bindings for NVIDIA cuDNN (R5) kernels.
注意: cu* 库都需要 cuda 的支持,如果 cuda 版本发生改变,库也需要重新安装; cudnn 的实现基于不同的Nvidia CuDNN 版本,要确认当前使用的是否一致。
- cuDNN v5 (May 12, 2016), for CUDA 7.5
- cuDNN v4 (Feb 10, 2016), for CUDA 7.0 and later
更详尽的 Cheatsheet。至此,可以玩起来了~