自己创建的parameter和函数为什么不优化?需要加什么操作吗??比如这个例子
Created by: jianjianGJ
import paddle.fluid.layers as layers
place = fluid.CPUPlace()
exe = fluid.Executor(place)
W = layers.create_parameter(shape=[1], dtype='float32')
y = 2*W;
adam = fluid.optimizer.Adam(learning_rate=0.1)
adam.minimize(y,parameter_list=[W])
exe.run(fluid.default_startup_program())
for i in range(3):
result,w = exe.run(fluid.default_main_program(),
fetch_list=[y, W])
print("y:",result,";w:",w)
输出:
y: [2.383992] ;w: [1.191996]
y: [2.383992] ;w: [1.191996]
y: [2.383992] ;w: [1.191996]