关于set_value对tensor中单个元素赋值无效问题
Created by: Reatris
1)PaddlePaddle版本:请提供您的PaddlePaddle版本号:1.8.4 平台gpu 只对整个tensor赋值有效,单个元素无效 代码如下
with fluid.dygraph.guard():
a = [[1,2,3,4,5],[6,7,8,9,0]]
b = [[6,6,6,6,6],[6,7,8,9,0]]
b = np.array(b)
b = fluid.dygraph.to_variable(b)
a = np.array(a)
af = np.array([4])
ae = fluid.dygraph.to_variable(af).astype('int64')
a = fluid.dygraph.to_variable(a)
a[0,1].set_value(ae)
print(a[0,1])
a.set_value(b)
print(a)
输出结果
运行耗时: 8毫秒
name tmp_4, dtype: VarType.INT64 shape: [1] lod: {}
dim: 1
layout: NCHW
dtype: int64_t
data: [2]
name generated_var_2, dtype: VarType.INT64 shape: [2, 5] lod: {}
dim: 2, 5
layout: NCHW
dtype: int64_t
data: [6 6 6 6 6 6 7 8 9 0]