MCPcopy Create free account
hub / github.com/apple/ml-pointersect / HyperParams

Class HyperParams

cdslib/core/nn/nn_utils.py:307–386  ·  view source on GitHub ↗

A dictionary that contains the hyper-parameters of a Network.

Source from the content-addressed store, hash-verified

305
306
307class HyperParams(ABC, MutableMapping):
308 """A dictionary that contains the hyper-parameters of a Network."""
309
310 class TBD(Enum):
311 ANY = enum.auto()
312 INT = enum.auto()
313 FLOAT = enum.auto()
314 STR = enum.auto()
315 DICT = enum.auto()
316 LIST = enum.auto()
317 SET = enum.auto()
318 TENSOR = enum.auto()
319 NDARRAY = enum.auto()
320 PARAM = enum.auto()
321 BOOL = enum.auto()
322
323 def __init__(self, *args, **kwargs):
324 self.param_dict: T.Dict[str, T.Any] = dict() # name -> value of all params
325 self.param_dict.update(*args, **kwargs)
326
327 def __str__(self):
328 return str(self.param_dict)
329
330 def __repr__(self):
331 return str(self.param_dict)
332
333 def __getitem__(self, key):
334 return self.param_dict[key]
335
336 def __setitem__(self, key, value):
337 self.param_dict[key] = value
338
339 def __delitem__(self, key):
340 del self.param_dict[key]
341
342 def __iter__(self):
343 return iter(self.param_dict)
344
345 def __len__(self):
346 return len(self.param_dict)
347
348 def check_valid(self):
349 return self.check_dict_valid(d=self.param_dict)
350 # valid = True
351 # for key, val in self.param_dict.items():
352 # if isinstance(val, HyperParams):
353 # valid = valid and val.check_valid()
354 # if not valid:
355 # return False
356 # elif isinstance(val, dict):
357 # for k, v in val.items():
358 # if isinstance(v, HyperParams.TBD):
359 # return False
360 # elif isinstance(val, (list, tuple, set)):
361 # for v in val:
362 # if isinstance(v, HyperParams.TBD):
363 # return False
364 # elif isinstance(val, HyperParams.TBD):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected