Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Jan 25, 2021
1 parent 6b23877 commit bc23966
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pytorch_lightning/core/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self, model, mode: str = MODE_DEFAULT):
self._model = model
self._mode = mode
self._layer_summary = self.summarize()
self._precision_megabytes = (self._model.precision / 8.0) * 1e-6 # 1 byte -> 8 bits
self._precision_megabytes = (self._model.precision / 8.0) * 1e-6 # 1 byte -> 8 bits

@property
def named_modules(self) -> List[Tuple[str, nn.Module]]:
Expand Down Expand Up @@ -389,9 +389,11 @@ def get_gpu_memory_map() -> Dict[str, int]:
}
return gpu_memory_map


def get_formatted_model_size(total_model_size: float) -> float:
return f"{total_model_size:,.3f}"


def get_human_readable_count(number: int) -> str:
"""
Abbreviates an integer number with K, M, B, T for thousands, millions,
Expand Down
3 changes: 1 addition & 2 deletions pytorch_lightning/loggers/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
_WANDB_AVAILABLE = _module_available("wandb")

try:
from wandb.wandb_run import Run

import wandb
from wandb.wandb_run import Run
except ImportError:
# needed for test mocks, these tests shall be updated
wandb, Run = None, None
Expand Down
5 changes: 3 additions & 2 deletions tests/core/test_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class PreCalculatedModel(BoringModel):

def __init__(self, precision: int = 32):
super().__init__()
self.layer = nn.Linear(32, 1000, bias=False) # 32K params
self.layer1 = nn.Linear(1000, 218, bias=False) # 218K params
self.layer = nn.Linear(32, 1000, bias=False) # 32K params
self.layer1 = nn.Linear(1000, 218, bias=False) # 218K params

# calculate model size based on precision.
self.pre_calculated_model_size = 1.0 / (32 / precision)
Expand All @@ -50,6 +50,7 @@ def forward(self, x):
x = self.layer(x)
return self.layer1(x)


class UnorderedModel(LightningModule):
""" A model in which the layers not defined in order of execution """

Expand Down

0 comments on commit bc23966

Please sign in to comment.