Skip to content

Commit

Permalink
add sample code for summary (PaddlePaddle#33337)
Browse files Browse the repository at this point in the history
  • Loading branch information
LielinJiang committed Jun 8, 2021
1 parent 5e09d67 commit f1045b7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/paddle/hapi/model_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ def forward(self, inputs):
params_info = paddle.summary(lenet, (1, 1, 28, 28))
print(params_info)
# multi input demo
class LeNetMultiInput(LeNet):
def forward(self, inputs, y):
x = self.features(inputs)
if self.num_classes > 0:
x = paddle.flatten(x, 1)
x = self.fc(x + y)
return x
lenet_multi_input = LeNetMultiInput()
params_info = paddle.summary(lenet_multi_input, [(1, 1, 28, 28), (1, 400)],
['float32', 'float32'])
print(params_info)
"""
if isinstance(input_size, InputSpec):
_input_size = tuple(input_size.shape)
Expand Down

0 comments on commit f1045b7

Please sign in to comment.