Skip to content

Commit 8461ab1

Browse files
authored
add sample code for summary (#33337) (#33427)
1 parent dfa05da commit 8461ab1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/paddle/hapi/model_summary.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ def forward(self, inputs):
8080
params_info = paddle.summary(lenet, (1, 1, 28, 28))
8181
print(params_info)
8282
83+
# multi input demo
84+
class LeNetMultiInput(LeNet):
85+
86+
def forward(self, inputs, y):
87+
x = self.features(inputs)
88+
89+
if self.num_classes > 0:
90+
x = paddle.flatten(x, 1)
91+
x = self.fc(x + y)
92+
return x
93+
94+
lenet_multi_input = LeNetMultiInput()
95+
96+
params_info = paddle.summary(lenet_multi_input, [(1, 1, 28, 28), (1, 400)],
97+
['float32', 'float32'])
98+
print(params_info)
99+
83100
"""
84101
if isinstance(input_size, InputSpec):
85102
_input_size = tuple(input_size.shape)

0 commit comments

Comments
 (0)