Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#11 from guoshengCS/input-to-list
Browse files Browse the repository at this point in the history
Add Layer.__init__ in Input.__init__
  • Loading branch information
qingqing01 committed Mar 17, 2020
2 parents 358f785 + 5e0a35f commit e8d52f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def extract_args(func):

class Input(fluid.dygraph.Layer):
def __init__(self, shape=None, dtype=None, name=None):
super(Input, self).__init__()
self.shape = shape
self.dtype = dtype
self.name = name
Expand Down Expand Up @@ -429,7 +430,7 @@ def train(self, inputs, labels=None):
inputs = to_list(inputs)
if labels is not None:
labels = to_list(labels)
outputs = self.model.forward(*[to_variable(x) for x in inputs])
outputs = self.model.forward(* [to_variable(x) for x in inputs])
losses = self.model._loss_function(outputs, labels)
final_loss = fluid.layers.sum(losses)
final_loss.backward()
Expand All @@ -444,7 +445,7 @@ def eval(self, inputs, labels=None):
inputs = to_list(inputs)
if labels is not None:
labels = to_list(labels)
outputs = self.model.forward(*[to_variable(x) for x in inputs])
outputs = self.model.forward(* [to_variable(x) for x in inputs])

if self.model._loss_function:
losses = self.model._loss_function(outputs, labels)
Expand Down

0 comments on commit e8d52f6

Please sign in to comment.