contribs.torchsummary.summary¶
Function ยท Source
params_info = mdnc.contribs.torchsummary.summary(
model, input_size, batch_size=-1, device='cuda:0', dtypes=None
)
Iterate the whole pytorch model and summarize the infomation as a Keras-style text report. The output would be store in a str.
Arguments¶
Requries
Argument | Type | Description |
---|---|---|
model | nn.Module | The pyTorch network module instance. It is to be analyzed. |
input_size | (seq/int, ) | A sequence (list/tuple ) or a sequence of sequnces, indicating the size of the each model input variable. |
batch_size | int | The batch size used for testing and displaying the results. |
device | str ortorch.device | Should be set according to the deployed device of the argument model . |
dtypes | (torch.dtype, ) | A sequence of torch data type for each input variable. If set None , would use float type for all variables. |
Returns
Argument | Description |
---|---|
params_info | A tuple of two values. The first value is the total parameter numbers. The second value is the trainable parameter numbers. |
Examples¶
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
----------------------------------------------------------------
Layer (type) Output Shape Param #
================================================================
Linear-1 [-1, 1, 50] 15,050
Linear-2 [-1, 1, 10] 510
Linear-3 [-1, 1, 50] 15,050
Linear-4 [-1, 1, 10] 510
TestTupleOutModule-5 [-1, 1, 10] 0
[-1, 1, 10]
[-1, 1, 10]
================================================================
Total params: 31,120
Trainable params: 31,120
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 0.00
Forward/backward pass size (MB): 0.00
Params size (MB): 0.12
Estimated Total Size (MB): 0.12
----------------------------------------------------------------
Last update: March 14, 2021