静态图模式下如何将numpy数组传入层以作为常量使用?
Created by: Yogurt2019
Hi,我在使用静态图模式时,需要向主程序传入一个常量以供使用,在静态图模式下如何实现传入一个常量呢? 我试过使用Tensor中的set()方法,但是在进行矩阵乘法的时候报错:
- File "/home/ddj2/PycharmProjects/image_classification_tax/build_model.py", line 69, in _tax_model
-
p = fluid.layers.matmul(mask, base_result_sf, transpose_x=False, transpose_y=True)
- File "/home/ddj2/.conda/envs/paddle/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 6777, in matmul
-
__check_input(x, y)
- File "/home/ddj2/.conda/envs/paddle/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 6752, in __check_input
-
x_shape = list(x.shape)
- TypeError: 'method' object is not iterable 我只是想传入一个数组常量以和算出来的loss进行乘法计算