【论文复现】module 'paddle' has no attribute 'tensor'
Created by: fly1642
运行代码示例: import paddle import paddle.fluid as fluid import numpy as np input_3 = np.random.randint(0, 100, [100, ]).astype('int32') input_4 = np.random.randint(0, 100, [200, ]).astype('int32') with fluid.dygraph.guard(): tensor_3 = fluid.dygraph.to_variable(input_3) tensor_4 = fluid.dygraph.to_variable(input_4) grid_x, grid_y = paddle.tensor.meshgrid([tensor_3, tensor_4])
报错: ---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in 7 tensor_3 = fluid.dygraph.to_variable(input_3) 8 tensor_4 = fluid.dygraph.to_variable(input_4) ----> 9 grid_x, grid_y = paddle.tensor.meshgrid([tensor_3, tensor_4]) 10 # grid_x, grid_y = fluid.layers.meshgrid([tensor_3, tensor_4]) 11 # print(grid_x,grid_y) AttributeError: module 'paddle' has no attribute 'tensor'
API文档有错误: https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/layers_cn/meshgrid_cn.html#meshgrid
paddle.tensor.meshgrid改为fluid.layers.meshgrid运行成功