反向传播不更新参数,跪求大佬指点迷津
Created by: xyq019971
b21=enet.block4(b20) b22= fluid.layers.transpose(b21, perm=[0, 2, 3, 1]) out1=fluid.layers.reshape(b22,shape=[-1,9]) out2=fluid.layers.reshape(y,shape=[-1,1]) #out3=paddle.fluid.layers.softmax(out1) _, out4 = fluid.layers.topk(out1, k=1) out5 = fluid.layers.cast(out4, dtype='float32') loss=paddle.fluid.layers.square_error_cost(out5, out2) avg=fluid.layers.reduce_mean(loss) regularizer = fluid.regularizer.L2Decay(0.0001) optimizer = paddle.fluid.optimizer.AdamOptimizer(learning_rate=0.01, beta1=0.9, beta2=0.999, epsilon=1e-08, regularization=regularizer) _, params_grads = optimizer.minimize(avg)
代码很简单就是一个9通道的图进来之后做一个语意分割反向传播,程序一直可以运行,但是就是参数不更新,如果用1张图片训练avg永远都是那个数字不变。