mxnet.context.cpu¶
-
mxnet.context.
cpu
(device_id=0)[source]¶ Returns a CPU context.
This function is a short cut for
Context('cpu', device_id)
. For most operations, when no context is specified, the default context is cpu().Examples
>>> with mx.cpu(): ... cpu_array = mx.nd.ones((2, 3)) >>> cpu_array.context cpu(0) >>> cpu_array = mx.nd.ones((2, 3), ctx=mx.cpu()) >>> cpu_array.context cpu(0)
- Parameters
device_id (int, optional) – The device id of the device. device_id is not needed for CPU. This is included to make interface compatible with GPU.
- Returns
context – The corresponding CPU context.
- Return type