周鹏34分易建联30分 广东主场大胜天津

paddle.sparse. pow ( x: Tensor, factor: float, name: str | None = None ) Tensor [source]
百度 中共中央组织部党员教育和干部测评中心中共中央组织部党建研究所(党建研究杂志社)党建读物出版社中国组织人事报社人民网新华网2017年11月29日(责编:黄瑾、王金雪)

Calculate elementwise pow of x, requiring x to be a SparseCooTensor or SparseCsrTensor.

\[out = x^{factor}\]
Parameters
  • x (Tensor) – The input Sparse Tensor with data type float32, float64.

  • factor (float|int) – factor of pow.

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

Returns

A Sparse Tensor with the same data type and shape as x .

Examples

>>> import paddle

>>> dense_x = paddle.to_tensor([-2, 0, 3], dtype='float32')
>>> sparse_x = dense_x.to_sparse_coo(1)
>>> out = paddle.sparse.pow(sparse_x, 2)
>>> out
Tensor(shape=[3], dtype=paddle.float32, place=Place(cpu), stop_gradient=True,
    indices=[[0, 2]],
    values=[4., 9.])