megengine.Parameter

class Parameter(data, dtype=None, device=None, is_const=False, no_cache=False, name=None, format='default')[source]

A kind of Tensor that is to be considered a module parameter.

Note

Operations happened on Parameter usually return a Tensor instead of Parameter. For example, with a Parameter x, x.reshape/to/sum/... will result into a Tensor. Any operations between Parameter and Tensor will have Tensor as outputs.

Attributes

T

alias of transpose.

device

Returns a string represents the device a Tensor storaged on.

dmap_callback

callback for device mapping, see load.

dtype

Returns a numpy.dtype object represents the data type of a Tensor.

format

Returns a string represents the memory format of a Tensor.

grad

gradient of this tensor, see autodiff.

name

Returns a string represents the name of a Tensor.

ndim

Returns the number of dimensions of self Tensor.

qparams

Returns a QParams object containing quantization params of a Tensor.

requires_grad

Returns a bool indicates whether the Tensor requires gradient.

shape

Returns a tuple or a Tensor represents tensor dimensions.

size

Returns the size of the self Tensor.

Methods

astype(dtype)

Returns a Tensor with the same data and number of elements with the specified dtype.

detach()

Returns a new Tensor, detached from the current graph.

flatten([start_axis, end_axis])

See flatten.

graph

item(*args)

Returns the value of this Tensor as a standard Python numbers.Number.

max([axis, keepdims])

See max.

mean([axis, keepdims])

See mean.

min([axis, keepdims])

See min.

numpy()

Returns self Tensor as a numpy.ndarray.

prod([axis, keepdims])

See prod.

reset_zero()

Deprecated since version 1.0.

reshape(*args)

See reshape.

set_value(value)

Deprecated since version 1.0.

sum([axis, keepdims])

See sum.

to(device, *[, _borrow])

Copy self Tensor to specified device.

tolist()

Returns the tensor as a (nested) list.

transpose(*args)

See transpose.

value_id

var