Skip to content

Commit be440b1

Browse files
committed
explicitly convert hyper params variable to a dict before filtering with ignore
1 parent 1d54103 commit be440b1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lightning/pytorch/utilities/parsing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import types
2020
from dataclasses import fields, is_dataclass
2121
from typing import Any, Dict, List, Literal, MutableMapping, Optional, Sequence, Tuple, Type, Union
22+
from argparse import Namespace
2223

2324
from torch import nn
2425

@@ -203,6 +204,8 @@ def save_hyperparameters(
203204
# `hparams` are expected here
204205

205206
# filter out hp based on ignore list
207+
if isinstance(hp, Namespace):
208+
hp = vars(hp)
206209
hp = {k: v for k, v in hp.items() if k not in ignore}
207210
obj._set_hparams(hp)
208211

0 commit comments

Comments
 (0)