megengine.Parameter

class Parameter(data, dtype=None, device=None, is_const=False, no_cache=False, name=None)[源代码]

一类表示模块参数的张量。

注解

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.

属性

T

alias of transpose.

c_name

device

Returns a string represents the device a Tensor storaged on.

dmap_callback

dtype

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

grad

name

ndim

返回自身 Tensor 的维数。

qparams

Returns a QParams object containing quantization params of a Tensor.

requires_grad

shape

Returns a tuple or a Tensor represents tensor dimensions.

size

Returns the size of the self Tensor.

方法

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()

See flatten.

item(*args)

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

max([axis, keepdims])

Returns the max value of each row of the input tensor in the given dimension axis.

mean([axis, keepdims])

Returns the mean value of each row of the input tensor in the given dimension axis.

min([axis, keepdims])

Returns the min value of each row of the input tensor in the given dimension axis.

numpy()

Returns self Tensor as a numpy.ndarray.

prod([axis, keepdims])

Returns the product of each row of the input tensor in the given dimension axis.

reset_zero()

1.0 版后已移除.

reshape(*args)

See reshape.

set_value(value)

1.0 版后已移除.

sum([axis, keepdims])

Returns the sum of each row of the input tensor in the given dimension axis.

to(device)

Copy self Tensor to specified device.

tolist()

Returns the tensor as a (nested) list.

transpose(*args)

See transpose.