2017年湖北省十堰市19930人报名高考 人数七连降

paddle. scale ( x: Tensor, scale: float | Tensor = 1.0, bias: float = 0.0, bias_after_scale: bool = True, act: str | None = None, name: str | None = None ) Tensor [source]
百度 新型政党制度,能够真实、广泛、持久代表和实现最广大人民根本利益这一新型政党制度,新就新在它是马克思主义政党理论同中国实际相结合的产物,能够真实、广泛、持久代表和实现最广大人民根本利益、全国各族各界根本利益,有效避免了旧式政党制度代表少数人、少数利益集团的弊端。

Scale operator.

Putting scale and bias to the input Tensor as following:

bias_after_scale is True:

\[Out=scale*X+bias\]

bias_after_scale is False:

\[Out=scale*(X+bias)\]
Parameters
  • x (Tensor) – Input N-D Tensor of scale operator. Data type can be bfloat16, float16, float32, float64, int8, int16, int32, int64, uint8, complex64, complex128.

  • scale (float|Tensor) – The scale factor of the input, it should be a float number or a 0-D Tensor with shape [] and data type as float32.

  • bias (float) – The bias to be put on the input.

  • bias_after_scale (bool) – Apply bias addition after or before scaling. It is useful for numeric stability in some circumstances.

  • act (str|None, optional) – Activation applied to the output such as tanh, softmax, sigmoid, relu.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

Output Tensor of scale operator, with shape and data type same as input.

Return type

Tensor

Examples

>>> # scale as a float32 number
>>> import paddle

>>> data = paddle.arange(6).astype("float32").reshape([2, 3])
>>> print(data)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0., 1., 2.],
 [3., 4., 5.]])
>>> res = paddle.scale(data, scale=2.0, bias=1.0)
>>> print(res)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[1. , 3. , 5. ],
 [7. , 9. , 11.]])
>>> # scale with parameter scale as a Tensor
>>> import paddle

>>> data = paddle.arange(6).astype("float32").reshape([2, 3])
>>> print(data)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0., 1., 2.],
 [3., 4., 5.]])
>>> factor = paddle.to_tensor([2], dtype='float32')
>>> res = paddle.scale(data, scale=factor, bias=1.0)
>>> print(res)
Tensor(shape=[2, 3], dtype=float32, place=Place(cpu), stop_gradient=True,
[[1. , 3. , 5. ],
 [7. , 9. , 11.]])