import paddle
a = paddle.to_tensor([0, 0, 1, 1])
b = paddle.to_tensor([1.2, 1.3, 2.1, 2.4])
a * b  # int64 int * float = int ???
Tensor(shape=[4], dtype=int64, place=CPUPlace, stop_gradient=True,
       [0, 0, 2, 2])
c = paddle.to_tensor([1.2, 1.3, 2.1, 2])
a * c
Tensor(shape=[4], dtype=int64, place=CPUPlace, stop_gradient=True,
       [0, 0, 2, 2])
b * c
Tensor(shape=[4], dtype=float32, place=CPUPlace, stop_gradient=True,
       [1.44000006, 1.68999982, 4.40999937, 4.80000019])
1. * a
Tensor(shape=[4], dtype=float32, place=CPUPlace, stop_gradient=True,
       [0., 0., 1., 1.])

bool_a = paddle.to_tensor([True, False])
bool_a
Tensor(shape=[2], dtype=bool, place=CPUPlace, stop_gradient=True,
       [True , False])
bool_a.cast('int64')
Tensor(shape=[2], dtype=int64, place=CPUPlace, stop_gradient=True,
       [1, 0])

Share on: TwitterFacebookEmail

Comments


Related Posts


Published

Category

NLP

Tags

Contact