Skip to content
Snippets Groups Projects
Unverified Commit fd7917a7 authored by Zaida Zhou's avatar Zaida Zhou Committed by GitHub
Browse files

Refine the style of table (#941)

* Refine the style of table

* refine
parent aee2f6a6
No related branches found
No related tags found
No related merge requests found
...@@ -70,24 +70,24 @@ The return outputs is dict, which contains the following keys: ...@@ -70,24 +70,24 @@ The return outputs is dict, which contains the following keys:
- `out_table`: print related information by table - `out_table`: print related information by table
``` ```
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┓ +---------------------+----------------------+--------+--------------+
module #parameters or shape #flops #activations | module | #parameters or shape | #flops | #activations |
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━┩ +---------------------+----------------------+--------+--------------+
model 0.44K 0.4K 40 | model | 0.44K | 0.4K | 40 |
fc1 0.11K 100 10 | fc1 | 0.11K | 100 | 10 |
fc1.weight (10, 10) | fc1.weight | (10, 10) | | |
fc1.bias (10,) | fc1.bias | (10,) | | |
fc2 0.11K 100 10 | fc2 | 0.11K | 100 | 10 |
fc2.weight (10, 10) | fc2.weight | (10, 10) | | |
fc2.bias (10,) | fc2.bias | (10,) | | |
inner 0.22K 0.2K 20 | inner | 0.22K | 0.2K | 20 |
inner.fc1 0.11K 100 10 | inner.fc1 | 0.11K | 100 | 10 |
inner.fc1.weight (10, 10) | inner.fc1.weight | (10, 10) | | |
inner.fc1.bias (10,) | inner.fc1.bias | (10,) | | |
inner.fc2 0.11K 100 10 | inner.fc2 | 0.11K | 100 | 10 |
inner.fc2.weight (10, 10) | inner.fc2.weight | (10, 10) | | |
inner.fc2.bias (10,) | inner.fc2.bias | (10,) | | |
└─────────────────────┴──────────────────────┴────────┴──────────────┘ +---------------------+----------------------+--------+--------------+
``` ```
- `out_arch`: print related information by network layers - `out_arch`: print related information by network layers
......
...@@ -5,6 +5,7 @@ from collections import defaultdict ...@@ -5,6 +5,7 @@ from collections import defaultdict
from typing import Any, Counter, DefaultDict, Dict, Optional, Tuple, Union from typing import Any, Counter, DefaultDict, Dict, Optional, Tuple, Union
import torch.nn as nn import torch.nn as nn
from rich import box
from rich.console import Console from rich.console import Console
from rich.table import Table from rich.table import Table
from torch import Tensor from torch import Tensor
...@@ -341,7 +342,8 @@ def parameter_count_table(model: nn.Module, max_depth: int = 3) -> str: ...@@ -341,7 +342,8 @@ def parameter_count_table(model: nn.Module, max_depth: int = 3) -> str:
rows.append(('model', format_size(count.pop('')))) rows.append(('model', format_size(count.pop(''))))
fill(0, '') 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('name')
table.add_column('#elements or shape') table.add_column('#elements or shape')
......
...@@ -7,6 +7,7 @@ from collections import defaultdict ...@@ -7,6 +7,7 @@ from collections import defaultdict
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
import torch import torch
from rich import box
from rich.console import Console from rich.console import Console
from rich.table import Table from rich.table import Table
from torch import nn from torch import nn
...@@ -421,7 +422,7 @@ def _stats_table_format( ...@@ -421,7 +422,7 @@ def _stats_table_format(
root_prefix = root_name + ('.' if root_name else '') root_prefix = root_name + ('.' if root_name else '')
fill(indent_lvl=1, prefix=root_prefix) fill(indent_lvl=1, prefix=root_prefix)
table = Table() table = Table(box=box.ASCII2)
for header in headers: for header in headers:
table.add_column(header) table.add_column(header)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment