dalgu90 / icd-coding-benchmark

Automatic ICD coding benchmark based on the MIMIC dataset
MIT License
35 stars 5 forks source link

Model Summary #34

Closed abheesht17 closed 2 years ago

abheesht17 commented 2 years ago

This PR adds an option in run.py to print the summary of a model (using torchsummaryX).

Example: DCAN

=====================================================================================================================================
                                                                                      Kernel Shape  \
Layer                                                                                                
0_word_embedding_layer.Embedding_embed                                                [100, 49800]   
1_word_embedding_layer.Dropout_dropout                                                           -   
2_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Conv1d_conv_layer               -   
3_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Chomp1d_chomp1d                 -   
4_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.ReLU_activation                 -   
5_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Dropout_dropout                 -   
6_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Conv1d_conv_layer               -   
7_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Chomp1d_chomp1d                 -   
8_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.ReLU_activation                 -   
9_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Dropout_dropout                 -   
10_temporal_conv_net.temporal_blocks.0.Conv1d_downsample                             [100, 600, 1]   
11_temporal_conv_net.temporal_blocks.0.ReLU_output_activation                                    -   
12_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Conv1d_conv_layer              -   
13_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Chomp1d_chomp1d                -   
14_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.ReLU_activation                -   
15_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Dropout_dropout                -   
16_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Conv1d_conv_layer              -   
17_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Chomp1d_chomp1d                -   
18_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.ReLU_activation                -   
19_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Dropout_dropout                -   
20_temporal_conv_net.temporal_blocks.1.ReLU_output_activation                                    -   
21_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Conv1d_conv_layer              -   
22_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Chomp1d_chomp1d                -   
23_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.ReLU_activation                -   
24_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Dropout_dropout                -   
25_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Conv1d_conv_layer              -   
26_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Chomp1d_chomp1d                -   
27_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.ReLU_activation                -   
28_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Dropout_dropout                -   
29_temporal_conv_net.temporal_blocks.2.ReLU_output_activation                                    -   
30_linear_layer                                                                         [600, 256]   
31_activation                                                                                    -   

                                                                                     Output Shape  \
Layer                                                                                               
0_word_embedding_layer.Embedding_embed                                               [1, 19, 100]   
1_word_embedding_layer.Dropout_dropout                                               [1, 19, 100]   
2_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Conv1d_conv_layer   [1, 600, 20]   
3_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Chomp1d_chomp1d     [1, 600, 19]   
4_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.ReLU_activation     [1, 600, 19]   
5_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Dropout_dropout     [1, 600, 19]   
6_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Conv1d_conv_layer   [1, 600, 20]   
7_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Chomp1d_chomp1d     [1, 600, 19]   
8_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.ReLU_activation     [1, 600, 19]   
9_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Dropout_dropout     [1, 600, 19]   
10_temporal_conv_net.temporal_blocks.0.Conv1d_downsample                             [1, 600, 19]   
11_temporal_conv_net.temporal_blocks.0.ReLU_output_activation                        [1, 600, 19]   
12_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Conv1d_conv_layer  [1, 600, 21]   
13_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Chomp1d_chomp1d    [1, 600, 19]   
14_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.ReLU_activation    [1, 600, 19]   
15_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Dropout_dropout    [1, 600, 19]   
16_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Conv1d_conv_layer  [1, 600, 21]   
17_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Chomp1d_chomp1d    [1, 600, 19]   
18_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.ReLU_activation    [1, 600, 19]   
19_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Dropout_dropout    [1, 600, 19]   
20_temporal_conv_net.temporal_blocks.1.ReLU_output_activation                        [1, 600, 19]   
21_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Conv1d_conv_layer  [1, 600, 23]   
22_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Chomp1d_chomp1d    [1, 600, 19]   
23_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.ReLU_activation    [1, 600, 19]   
24_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Dropout_dropout    [1, 600, 19]   
25_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Conv1d_conv_layer  [1, 600, 23]   
26_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Chomp1d_chomp1d    [1, 600, 19]   
27_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.ReLU_activation    [1, 600, 19]   
28_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Dropout_dropout    [1, 600, 19]   
29_temporal_conv_net.temporal_blocks.2.ReLU_output_activation                        [1, 600, 19]   
30_linear_layer                                                                      [1, 19, 256]   
31_activation                                                                        [1, 19, 256]   

                                                                                       Params  \
Layer                                                                                           
0_word_embedding_layer.Embedding_embed                                                      -   
1_word_embedding_layer.Dropout_dropout                                                      -   
2_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Conv1d_conv_layer     121.2k   
3_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Chomp1d_chomp1d            -   
4_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.ReLU_activation            -   
5_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Dropout_dropout            -   
6_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Conv1d_conv_layer     721.2k   
7_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Chomp1d_chomp1d            -   
8_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.ReLU_activation            -   
9_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Dropout_dropout            -   
10_temporal_conv_net.temporal_blocks.0.Conv1d_downsample                                60.6k   
11_temporal_conv_net.temporal_blocks.0.ReLU_output_activation                               -   
12_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Conv1d_conv_layer    721.2k   
13_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Chomp1d_chomp1d           -   
14_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.ReLU_activation           -   
15_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Dropout_dropout           -   
16_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Conv1d_conv_layer    721.2k   
17_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Chomp1d_chomp1d           -   
18_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.ReLU_activation           -   
19_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Dropout_dropout           -   
20_temporal_conv_net.temporal_blocks.1.ReLU_output_activation                               -   
21_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Conv1d_conv_layer    721.2k   
22_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Chomp1d_chomp1d           -   
23_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.ReLU_activation           -   
24_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Dropout_dropout           -   
25_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Conv1d_conv_layer    721.2k   
26_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Chomp1d_chomp1d           -   
27_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.ReLU_activation           -   
28_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Dropout_dropout           -   
29_temporal_conv_net.temporal_blocks.2.ReLU_output_activation                               -   
30_linear_layer                                                                      153.856k   
31_activation                                                                               -   

                                                                                    Mult-Adds  
Layer                                                                                          
0_word_embedding_layer.Embedding_embed                                                      -  
1_word_embedding_layer.Dropout_dropout                                                      -  
2_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Conv1d_conv_layer     120.6k  
3_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Chomp1d_chomp1d            -  
4_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.ReLU_activation            -  
5_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.0.Dropout_dropout            -  
6_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Conv1d_conv_layer     720.6k  
7_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Chomp1d_chomp1d            -  
8_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.ReLU_activation            -  
9_temporal_conv_net.temporal_blocks.0.conv_temporal_sub_blocks.1.Dropout_dropout            -  
10_temporal_conv_net.temporal_blocks.0.Conv1d_downsample                                1.14M  
11_temporal_conv_net.temporal_blocks.0.ReLU_output_activation                               -  
12_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Conv1d_conv_layer    720.6k  
13_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Chomp1d_chomp1d           -  
14_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.ReLU_activation           -  
15_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.0.Dropout_dropout           -  
16_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Conv1d_conv_layer    720.6k  
17_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Chomp1d_chomp1d           -  
18_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.ReLU_activation           -  
19_temporal_conv_net.temporal_blocks.1.conv_temporal_sub_blocks.1.Dropout_dropout           -  
20_temporal_conv_net.temporal_blocks.1.ReLU_output_activation                               -  
21_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Conv1d_conv_layer    720.6k  
22_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Chomp1d_chomp1d           -  
23_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.ReLU_activation           -  
24_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.0.Dropout_dropout           -  
25_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Conv1d_conv_layer    720.6k  
26_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Chomp1d_chomp1d           -  
27_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.ReLU_activation           -  
28_temporal_conv_net.temporal_blocks.2.conv_temporal_sub_blocks.1.Dropout_dropout           -  
29_temporal_conv_net.temporal_blocks.2.ReLU_output_activation                               -  
30_linear_layer                                                                        153.6k  
31_activation                                                                               -  
-------------------------------------------------------------------------------------------------------------------------------------
                         Totals
Total params          8.921656M
Trainable params      3.941656M
Non-trainable params      4.98M
Mult-Adds               5.0172M
=====================================================================================================================================
abheesht17 commented 2 years ago

Great job! It's really simple and effective way of doing this. I also like we put --model_summary to false as default and make it optional to print the summary.

Thanks, @dalgu90! :D

Should I merge it?

dalgu90 commented 2 years ago

Sure. I think we are good to go!