BERT model summary

Flying-flash: <p>I would like to print my BERT model summary (text classification). I know that for image classification we use summary(model,inputsize=(channel, height, width)).What dimensions can I give for text BERT?<br>
This is my print(model):</p>
<p>BertClassifier(<br>
(bert): BertModel(<br>
(embeddings): BertEmbeddings(<br>
(word_embeddings): Embedding(28996, 768, padding_idx=0)<br>
(position_embeddings): Embedding(512, 768)<br>
(token_type_embeddings): Embedding(2, 768)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(encoder): BertEncoder(<br>
(layer): ModuleList(<br>
(0): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(1): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(2): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(3): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(4): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(5): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(6): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(7): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(8): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(9): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(10): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(11): BertLayer(<br>
(attention): BertAttention(<br>
(self): BertSelfAttention(<br>
(query): Linear(in_features=768, out_features=768, bias=True)<br>
(key): Linear(in_features=768, out_features=768, bias=True)<br>
(value): Linear(in_features=768, out_features=768, bias=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
(output): BertSelfOutput(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
(intermediate): BertIntermediate(<br>
(dense): Linear(in_features=768, out_features=3072, bias=True)<br>
)<br>
(output): BertOutput(<br>
(dense): Linear(in_features=3072, out_features=768, bias=True)<br>
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)<br>
(dropout): Dropout(p=0.1, inplace=False)<br>
)<br>
)<br>
)<br>
)<br>
(pooler): BertPooler(<br>
(dense): Linear(in_features=768, out_features=768, bias=True)<br>
(activation): Tanh()<br>
)<br>
)<br>
(dropout): Dropout(p=0.5, inplace=False)<br>
(linear1): Linear(in_features=768, out_features=256, bias=True)<br>
(linear2): Linear(in_features=256, out_features=141, bias=True)<br>
(relu): ReLU()<br>
)</p>
<p>Could you help please?</p>

Flying-flash: <p>Solved!<br>
I used::<br>
pip install torch-summary<br>
summary(model,input_size=(768,),depth=1,batch_dim=1, dtypes=[‘torch.IntTensor’])</p>
<p>Thanks!!</p>