Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/datamodules/mnist_datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
self.data_test: Optional[Dataset] = None

@property
def num_classes(self) -> int:
def num_classes(self):
return 10

def prepare_data(self):
Expand Down Expand Up @@ -118,11 +118,11 @@ def teardown(self, stage: Optional[str] = None):
"""Clean up after fit or test."""
pass

def state_dict(self) -> Dict[str, Any]:
def state_dict(self):
"""Extra things to save to checkpoint."""
return {}

def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
def load_state_dict(self, state_dict: Dict[str, Any]):
"""Things to do when loading checkpoint."""
pass

Expand Down
4 changes: 2 additions & 2 deletions src/tasks/eval_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Tuple
from typing import List, Tuple

import hydra
from omegaconf import DictConfig
Expand All @@ -11,7 +11,7 @@


@utils.task_wrapper
def evaluate(cfg: DictConfig) -> Tuple[None, Dict[str, Any]]:
def evaluate(cfg: DictConfig) -> Tuple[dict, dict]:
"""Evaluates given checkpoint on a datamodule testset.

This method is wrapped in @task_wrapper decorator which applies extra utilities
Expand Down
4 changes: 2 additions & 2 deletions src/tasks/train_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Tuple
from typing import List, Tuple

import hydra
import pytorch_lightning as pl
Expand All @@ -12,7 +12,7 @@


@utils.task_wrapper
def train(cfg: DictConfig) -> Tuple[Optional[float], Dict[str, Any]]:
def train(cfg: DictConfig) -> Tuple[dict, dict]:
"""Trains the model. Can additionally evaluate on a testset, using best weights obtained during
training.

Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def extras(cfg: DictConfig) -> None:


@rank_zero_only
def save_file(path, content) -> None:
def save_file(path: str, content: str) -> None:
"""Save file in rank zero mode (only on one process in multi-GPU setup)."""
with open(path, "w+") as file:
file.write(content)
Expand Down Expand Up @@ -129,7 +129,7 @@ def instantiate_loggers(logger_cfg: DictConfig) -> List[LightningLoggerBase]:


@rank_zero_only
def log_hyperparameters(object_dict: Dict[str, Any]) -> None:
def log_hyperparameters(object_dict: dict) -> None:
"""Controls which config parts are saved by lightning loggers.

Additionally saves:
Expand Down