Checking if the parameters are a DictConfig Object (#2216)
* Checking if the parameters are a DictConfig Object This is in reference to #2058 . To be honest, I have no idea how I should go about writing a test for this. * Update pytorch_lightning/loggers/base.py Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> * fix ... Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> Co-authored-by: Jirka <jirka@pytorchlightning.ai>
This commit is contained in:
parent
bdee1cd106
commit
44385bb582
|
@ -3,13 +3,11 @@ import functools
|
|||
import operator
|
||||
from abc import ABC, abstractmethod
|
||||
from argparse import Namespace
|
||||
from typing import Union, Optional, Dict, Iterable, Any, Callable, List, Sequence, Mapping, Tuple
|
||||
from typing import Union, Optional, Dict, Iterable, Any, Callable, List, Sequence, Mapping, Tuple, MutableMapping
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
from pytorch_lightning.utilities import rank_zero_only
|
||||
|
||||
|
||||
class LightningLoggerBase(ABC):
|
||||
"""
|
||||
|
@ -174,9 +172,9 @@ class LightningLoggerBase(ABC):
|
|||
|
||||
def _dict_generator(input_dict, prefixes=None):
|
||||
prefixes = prefixes[:] if prefixes else []
|
||||
if isinstance(input_dict, dict):
|
||||
if isinstance(input_dict, MutableMapping):
|
||||
for key, value in input_dict.items():
|
||||
if isinstance(value, (dict, Namespace)):
|
||||
if isinstance(value, (MutableMapping, Namespace)):
|
||||
value = vars(value) if isinstance(value, Namespace) else value
|
||||
for d in _dict_generator(value, prefixes + [key]):
|
||||
yield d
|
||||
|
|
Loading…
Reference in New Issue