Skip to content

Commit

Permalink
Further simplify the typing in the example
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <[email protected]>
  • Loading branch information
lebrice committed Jul 17, 2024
1 parent 905d3a4 commit 8631015
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions project/algorithms/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dataclasses
import functools
from logging import getLogger
from typing import Annotated, Any, Literal
from typing import Any, Literal

import pydantic
import torch
Expand All @@ -26,8 +26,6 @@

logger = getLogger(__name__)

LRSchedulerConfig = Annotated[Any, pydantic.Field(default_factory=CosineAnnealingLRConfig)]


class ExampleAlgorithm(LightningModule):
"""Example learning algorithm for image classification."""
Expand All @@ -37,11 +35,7 @@ class HParams:
"""Hyper-Parameters."""

# Arguments to be passed to the LR scheduler.
lr_scheduler: LRSchedulerConfig = dataclasses.field(
default=CosineAnnealingLRConfig(T_max=85, eta_min=1e-5),
metadata={"omegaconf_ignore": True},
)

lr_scheduler: Any = CosineAnnealingLRConfig(T_max=85, eta_min=1e-5)
lr_scheduler_interval: Literal["step", "epoch"] = "epoch"

# Frequency of the LR scheduler. Set to 0 to disable the lr scheduler.
Expand Down

0 comments on commit 8631015

Please sign in to comment.