Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 authored and leej3 committed May 21, 2024
1 parent 03747ec commit a4ecda8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ignite/handlers/lr_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def __init__(
# override base_lrs
self.base_lrs = start_lrs

def get_lr(self) -> List[float]: # type: ignore[override]
def get_lr(self) -> List[float]:
curr_iter = self.last_epoch + 1
r = curr_iter / self.num_iter
return [base_lr * (end_lr / base_lr) ** r for end_lr, base_lr in zip(self.end_lrs, self.base_lrs)]
6 changes: 3 additions & 3 deletions ignite/handlers/param_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections import OrderedDict
from copy import copy
from pathlib import Path
from typing import Any, cast, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union

import torch
from torch.optim.lr_scheduler import CosineAnnealingWarmRestarts, ReduceLROnPlateau
Expand Down Expand Up @@ -992,7 +992,7 @@ def get_param(self) -> Union[float, List[float]]:
"""Method to get current optimizer's parameter value"""
# Emulate context manager for pytorch>=1.4
self.lr_scheduler._get_lr_called_within_step = True # type: ignore[union-attr]
lr_list = cast(List[float], self.lr_scheduler.get_lr())
lr_list = self.lr_scheduler.get_lr()
self.lr_scheduler._get_lr_called_within_step = False # type: ignore[union-attr]
if len(lr_list) == 1:
return lr_list[0]
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def __init__(
_scheduler_kwargs["verbose"] = False

self.scheduler = ReduceLROnPlateau(optimizer, **_scheduler_kwargs)
self.scheduler._reduce_lr = self._reduce_lr # type: ignore[attr-defined]
self.scheduler._reduce_lr = self._reduce_lr # type: ignore[method-assign]

self._state_attrs += ["metric_name", "scheduler"]

Expand Down

0 comments on commit a4ecda8

Please sign in to comment.