Tensor¶
- class
dragon.
Tensor
(
shape=None,
dtype='float32',
name=None,
symbolic=False,
**kwargs
)[source]¶ A multi-dimensional array for computation.
__init__¶
Tensor.
__init__
(
shape=None,
dtype='float32',
name=None,
symbolic=False,
**kwargs
)[source]¶Create a
Tensor
.- Parameters:
- shape (Sequence[int], optional) – The tensor shape.
- dtype (str, optional, default='float32') – The data type.
- name (str, optional) – The tensor name.
- symbolic (bool, optional, default=False) – Whether to initialize as a symbolic tensor.
Properties¶
requires_grad¶
Tensor.
requires_grad
¶Return whether the gradient will be recorded.
- Returns:
- bool –
True
to record gradient otherwiseFalse
.
Methods¶
astype¶
copy¶
fill¶
glorot_normal¶
Tensor.
glorot_normal
(
mode='fan_in',
scale=2.0
)[source]¶Fill self from a glorot normal distribution.
- Parameters:
- mode ({'fan_in, 'fan_out', 'fan_avg'}, optional) – The mode to compute fans.
- scale (float, optional, default=2.0) – The scale factor of distribution.
- Returns:
dragon.Tensor – The self.
See also
glorot_uniform¶
Tensor.
glorot_uniform
(
mode='fan_in',
scale=3.0
)[source]¶Fill self from a glorot uniform distribution.
- Parameters:
- mode ({'fan_in, 'fan_out', 'fan_avg'}, optional) – The mode to compute fans.
- scale (float, optional, default=3.0) – The scale factor of distribution.
- Returns:
dragon.Tensor – The self.
See also
normal¶
numpy¶
reshape¶
Tensor.
reshape
(
shape,
copy=True
)[source]¶Return a tensor containing the same data with new shape.
- Parameters:
- shape (Union[Sequence[int], dragon.Tensor]) – The output shape.
- copy (bool, optional, default=True) – Return a new tensor or reshape in-place.
- Returns:
dragon.Tensor – The output tensor.
See also
transpose¶
Tensor.
transpose
(
perm=None,
copy=True
)[source]¶Return a tensor with permuted axes.
- Parameters:
- perm (Union[Sequence[int], dragon.Tensor]], optional) – The output permutation.
- copy (bool, optional, default=True) – Return a new tensor or transpose in-place.
- Returns:
dragon.Tensor – The output tensor.
See also
truncated_normal¶
Overrides¶
__add__¶
Tensor.
__add__
(other)[source]¶Compute the element-wise addition.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to add.
- Returns:
dragon.Tensor – The output tensor.
See also
__and__¶
Tensor.
__and__
(other)[source]¶Compute the element-wise AND bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also
__eq__¶
Tensor.
__eq__
(other)[source]¶Compute element-wise equal comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__float__¶
__ge__¶
Tensor.
__ge__
(other)[source]¶Compute element-wise greater-equal comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__getitem__¶
Tensor.
__getitem__
(item)[source]¶Select elements at the specific index.
- Parameters:
- item (Union[slice, int, dragon.Tensor]) – The index.
- Returns:
dragon.Tensor – The output tensor.
__gt__¶
Tensor.
__gt__
(other)[source]¶Compute element-wise greater comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__iadd__¶
Tensor.
__iadd__
(other)[source]¶Compute the element-wise addition.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to add.
- Returns:
dragon.Tensor – The self.
See also
__iand__¶
Tensor.
__iand__
(other)[source]¶Compute the element-wise AND bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The self.
See also
__imul__¶
Tensor.
__imul__
(other)[source]¶Compute the element-wise multiplication.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to multiply.
- Returns:
dragon.Tensor – The self.
See also
__int__¶
__invert__¶
__ior__¶
Tensor.
__ior__
(other)[source]¶Compute the element-wise OR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The self.
See also
__isub__¶
Tensor.
__isub__
(other)[source]¶Compute the element-wise subtraction.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to subtract.
- Returns:
dragon.Tensor – The self.
See also
__itruediv__¶
Tensor.
__itruediv__
(other)[source]¶Compute the element-wise division.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to divide.
- Returns:
dragon.Tensor – The self.
See also
__ixor__¶
Tensor.
__ixor__
(other)[source]¶Compute the element-wise XOR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The self.
See also
__le__¶
Tensor.
__le__
(other)[source]¶Compute element-wise less-equal comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__lt__¶
Tensor.
__lt__
(other)[source]¶Compute element-wise less comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__matmul__¶
Tensor.
__matmul__
(other)[source]¶Compute the matrix multiplication.
- Parameters:
- other (dragon.Tensor) – The value to multiply.
- Returns:
dragon.Tensor – The output tensor.
See also
__mul__¶
Tensor.
__mul__
(other)[source]¶Compute the element-wise multiplication.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to multiply.
- Returns:
dragon.Tensor – The output tensor.
See also
__ne__¶
Tensor.
__ne__
(other)[source]¶Compute element-wise not-equal comparison.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compare.
- Returns:
dragon.Tensor – The output tensor.
See also
__neg__¶
__or__¶
Tensor.
__or__
(other)[source]¶Compute the element-wise OR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also
__radd__¶
Tensor.
__radd__
(other)[source]¶Compute the element-wise addition.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to add.
- Returns:
dragon.Tensor – The output tensor.
See also
__rand__¶
Tensor.
__rand__
(other)[source]¶Compute the element-wise AND bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also
__rmul__¶
Tensor.
__rmul__
(other)[source]¶Compute the element-wise multiplication.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to multiply.
- Returns:
dragon.Tensor – The output tensor.
See also
__ror__¶
Tensor.
__ror__
(other)[source]¶Compute the element-wise OR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also
__rsub__¶
Tensor.
__rsub__
(other)[source]¶Compute the element-wise subtraction.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to be subtracted.
- Returns:
dragon.Tensor – The output tensor.
See also
__rxor__¶
Tensor.
__rxor__
(other)[source]¶Compute the element-wise XOR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also
__setitem__¶
Tensor.
__setitem__
(
key,
value
)[source]¶Set elements at the specific index.
- Parameters:
- key (Union[slice, int, dragon.Tensor]) – The index.
- value (Union[dragon.Tensor, number]) – The value to set.
__sub__¶
Tensor.
__sub__
(other)[source]¶Compute the element-wise subtraction.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to subtract.
- Returns:
dragon.Tensor – The output tensor.
See also
__rtruediv__¶
Tensor.
__rtruediv__
(other)[source]¶Compute the element-wise division.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to be divided.
- Returns:
dragon.Tensor – The output tensor.
See also
__truediv__¶
Tensor.
__truediv__
(other)[source]¶Compute the element-wise division.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to divide.
- Returns:
dragon.Tensor – The output tensor.
See also
__xor__¶
Tensor.
__xor__
(other)[source]¶Compute the element-wise XOR bitwise operation.
- Parameters:
- other (Union[dragon.Tensor, number]) – The value to compute with.
- Returns:
dragon.Tensor – The output tensor.
See also