官术网_书友最值得收藏!

MXNet

MXNet is a multi-language machine learning library. It offers two modes of computation:

  • Imperative mode: This mode exposes an interface much like regular NumPy like API. For example, to construct a tensor of zeros on both CPU and GPU using MXNet, you use the following code block:
import mxnet as mx
tensor_cpu = mx.nd.zeros((100,), ctx=mx.cpu())
tensor_gpu = mx.nd.zeros((100,), ctx=mx.gpu(0))

In the example earlier, MXNet specifies the location where to hold the tensor either in CPU or in a GPU device at location 0. One important distinction with MXNet is that all computations happen lazily instead of instantaneously. This allows MXNet to achieve incredible utilization of the device, unlike any other framework.

  • Symbolic mode: This mode exposes a computation graph like TensorFlow. Though the imperative API is quite useful, one of its drawbacks is its rigidity. All computations need to be known beforehand along with pre-defined data structures. Symbolic API aims to remove this limitation by allowing MXNet to work with symbols or variables instead of fixed data types. These symbols can then be compiled or interpreted to be executed as a set of operations as shown follows:
import mxnet as mx
x = mx.sym.Variable("X") # represent a symbol.
y = mx.sym.Variable("Y")
z = (x + y)
m = z / 100
主站蜘蛛池模板: 密云县| 垣曲县| 金川县| 久治县| 理塘县| 栖霞市| 桐庐县| 崇明县| 马龙县| 车险| 布拖县| 莱阳市| 霍州市| 新邵县| 宕昌县| 山阴县| 洪雅县| 保亭| 潜山县| 南江县| 新宾| 界首市| 海林市| 台前县| 潼南县| 丹凤县| 泗洪县| 交城县| 兴安盟| 黄骅市| 鹤岗市| 黔南| 米脂县| 墨竹工卡县| 大丰市| 临江市| 岢岚县| 哈巴河县| 南开区| 灵宝市| 水城县|