训练代码报错信息需要优化
Created by: lgone2000
如下面测试程序所示, default_startup_program 调用顺序不对,而报的错误比较乱,估计这种错误困扰了很多人, 希望paddle能改一下。
def test_error_report():
place = fluid.CPUPlace()
exe = fluid.Executor(place)
main_program = fluid.default_main_program()
x = fluid.layers.data(name='x', shape=[10], dtype='float32')
feature = fluid.layers.fc(name='fc', input=x, size=20, act=None)
loss = fluid.layers.reduce_mean(feature)
if 1:
#这个代码报错信息完全看不懂, 能否简单报一个,default_startup_program 应在minimize后执行?
exe.run(fluid.default_startup_program())
optimizer = fluid.optimizer.SGD(learning_rate=0.1)
opts = optimizer.minimize(loss)
else:
optimizer = fluid.optimizer.SGD(learning_rate=0.1)
opts = optimizer.minimize(loss)
exe.run(fluid.default_startup_program())
batch_data = np.random.rand(5,10).astype(np.float32)
output = exe.run(main_program,feed={'x': batch_data},fetch_list=[loss])