PaddleFleetX icon indicating copy to clipboard operation
PaddleFleetX copied to clipboard

文档代码在2.0rc不通过

Open skywalk163 opened this issue 5 years ago • 0 comments

文档地址:https://github.com/PaddlePaddle/FleetX/blob/develop/docs/source/paddle_fleet_rst/fleetrun_usage_cn.rst

在2.0rc版本会报错: AttributeError: module 'paddle' has no attribute 'data'

TypeError: fc() got an unexpected keyword argument 'input'

TypeError: fc() got an unexpected keyword argument 'input'

TypeError: fc() got an unexpected keyword argument 'act'

经查证,发现需要修改成如下语句:

def mnist_on_mlp_model():

train_dataset = paddle.vision.datasets.MNIST(mode='train')
test_dataset = paddle.vision.datasets.MNIST(mode='test')
x = paddle.fluid.data(name="x", shape=[64, 1, 28, 28], dtype='float32')
y = paddle.fluid.data(name="y", shape=[64, 1], dtype='int64')
x_flatten = fluid.layers.reshape(x, [64, 784])
fc_1 = nn.fc(x=x_flatten, size=128, activation='tanh') 
fc_2 = nn.fc(x=fc_1, size=128, activation='tanh') 
prediction = nn.fc(x=[fc_2], size=10, activation='softmax') 
cost = fluid.layers.cross_entropy(input=prediction, label=y)
acc_top1 = fluid.layers.accuracy(input=prediction, label=y, k=1)
avg_cost = fluid.layers.mean(x=cost)
return train_dataset, test_dataset, x, y, avg_cost, acc_top1

也就是paddle.data 改成paddle.fluid.data

fc_1 = nn.fc(input=x_flatten, size=128, act='tanh') 改成 fc_1 = nn.fc(x=x_flatten, size=128, activation='tanh')

skywalk163 avatar Nov 09 '20 14:11 skywalk163