assign¶
- paddle.fluid.layers.tensor. assign ( input, output=None ) [source]
- 
         The OP copies the inputto theoutput.- Parameters
- 
           - input (Tensor|numpy.ndarray|list|tuple|scalar) – A tensor, numpy ndarray, tuple/list of scalar, or scalar. Its data type supports float16, float32, float64, int32, int64, and bool. Note: the float64 data will be converted to float32 because of current platform protobuf data limitation. 
- output (Tensor, optional) – A tensor. If - outputis None, a new tensor will be created as- output. Default: None.
 
- Returns
- 
           A tensor with the same shape, data type and value as input.
- Return type
- 
           Tensor 
 Examples import paddle import numpy as np data = paddle.full(shape=[3, 2], fill_value=2.5, dtype='float64') # [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] array = np.array([[1, 1], [3, 4], [1, 3]]).astype(np.int64) result1 = paddle.zeros(shape=[3, 3], dtype='float32') paddle.assign(array, result1) # result1 = [[1, 1], [3 4], [1, 3]] result2 = paddle.assign(data) # result2 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] result3 = paddle.assign(np.array([[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]], dtype='float32')) # result3 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] 
