Refine the style of table (#941)

* Refine the style of table

* refine
This commit is contained in:
Zaida Zhou 2023-02-20 20:12:37 +08:00 committed by GitHub
parent aee2f6a688
commit fd7917a7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 20 deletions

View File

@ -70,24 +70,24 @@ The return outputs is dict, which contains the following keys:
- `out_table`: print related information by table
```
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ module ┃ #parameters or shape ┃ #flops#activations
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━┩
│ model │ 0.44K │ 0.4K │ 40 │
│ fc1 │ 0.11K │ 100 │ 10 │
│ fc1.weight │ (10, 10) │ │ │
│ fc1.bias │ (10,) │ │ │
│ fc2 │ 0.11K │ 100 │ 10 │
│ fc2.weight │ (10, 10) │ │ │
│ fc2.bias │ (10,) │ │ │
│ inner │ 0.22K │ 0.2K │ 20 │
│ inner.fc1 │ 0.11K │ 100 │ 10 │
│ inner.fc1.weight │ (10, 10) │ │ │
│ inner.fc1.bias │ (10,) │ │ │
│ inner.fc2 │ 0.11K │ 100 │ 10 │
│ inner.fc2.weight │ (10, 10) │ │ │
│ inner.fc2.bias │ (10,) │ │ │
└─────────────────────┴──────────────────────┴────────┴──────────────┘
+---------------------+----------------------+--------+--------------+
| module | #parameters or shape | #flops | #activations |
+---------------------+----------------------+--------+--------------+
| model | 0.44K | 0.4K | 40 |
| fc1 | 0.11K | 100 | 10 |
| fc1.weight | (10, 10) | | |
| fc1.bias | (10,) | | |
| fc2 | 0.11K | 100 | 10 |
| fc2.weight | (10, 10) | | |
| fc2.bias | (10,) | | |
| inner | 0.22K | 0.2K | 20 |
| inner.fc1 | 0.11K | 100 | 10 |
| inner.fc1.weight | (10, 10) | | |
| inner.fc1.bias | (10,) | | |
| inner.fc2 | 0.11K | 100 | 10 |
| inner.fc2.weight | (10, 10) | | |
| inner.fc2.bias | (10,) | | |
+---------------------+----------------------+--------+--------------+
```
- `out_arch`: print related information by network layers

View File

@ -5,6 +5,7 @@ from collections import defaultdict
from typing import Any, Counter, DefaultDict, Dict, Optional, Tuple, Union
import torch.nn as nn
from rich import box
from rich.console import Console
from rich.table import Table
from torch import Tensor
@ -341,7 +342,8 @@ def parameter_count_table(model: nn.Module, max_depth: int = 3) -> str:
rows.append(('model', format_size(count.pop(''))))
fill(0, '')
table = Table(title=f'parameter count of {model.__class__.__name__}')
table = Table(
title=f'parameter count of {model.__class__.__name__}', box=box.ASCII2)
table.add_column('name')
table.add_column('#elements or shape')

View File

@ -7,6 +7,7 @@ from collections import defaultdict
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
import torch
from rich import box
from rich.console import Console
from rich.table import Table
from torch import nn
@ -421,7 +422,7 @@ def _stats_table_format(
root_prefix = root_name + ('.' if root_name else '')
fill(indent_lvl=1, prefix=root_prefix)
table = Table()
table = Table(box=box.ASCII2)
for header in headers:
table.add_column(header)