# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import paddle.fluid as fluid class Model(object): def __init__(self): pass def mlp(self, inputs, label, hidden_size=128): self.concat = fluid.layers.concat(inputs, axis=1) self.fc1 = fluid.layers.fc(input=self.concat, size=256, act='relu') self.fc2 = fluid.layers.fc(input=self.fc1, size=128, act='relu') self.predict = fluid.layers.fc(input=self.fc2, size=2, act='softmax') self.sum_cost = fluid.layers.cross_entropy( input=self.predict, label=label) self.accuracy = fluid.layers.accuracy(input=self.predict, label=label) self.loss = fluid.layers.reduce_mean(self.sum_cost) self.startup_program = fluid.default_startup_program()