多元回归
Created by: wjwhappy
我想写一个多元回归,输入是8个特征,输出也是8维度 ` X = fluid.data(name='X', shape=[None, 8], dtype='float32') Y = fluid.data(name='Y', shape=[None, 8], dtype='float32')
h1 = fluid.layers.fc(input=X, size=100, act='tanh') h2 = fluid.layers.fc(input=h1, size=100, act='tanh') h3 = fluid.layers.fc(input=h2, size=100, act='tanh') pred = fluid.layers.fc(input=h3, size=8, act='tanh')
cost = fluid.layers.cross_entropy(input=pred, label=Y) avg_cost = fluid.layers.mean(cost)
adam_opt = fluid.optimizer.Adam(learning_rate=0.0003) adam_opt.minimize(avg_cost) ` 但是一直报错: InvalidArgumentError: the last dimension of Input(Label) should be 1.But received: the last dimension of Input(Label) is [8],the last dimension is [1] [Hint: Expected label_dims[rank - 1] == 1UL, but received label_dims[rank - 1]:8 != 1UL:1.] at (D:\1.8.4\paddle\paddle\fluid\operators\cross_entropy_op.cc:87) [operator < cross_entropy2 > error]