MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / get

Method get

tensorflow/contrib/training/python/training/hparam.py:635–660  ·  view source on GitHub ↗

Returns the value of `key` if it exists, else `default`.

(self, key, default=None)

Source from the content-addressed store, hash-verified

633 return {n: getattr(self, n) for n in self._hparam_types.keys()}
634
635 def get(self, key, default=None):
636 """Returns the value of `key` if it exists, else `default`."""
637 if key in self._hparam_types:
638 # Ensure that default is compatible with the parameter type.
639 if default is not None:
640 param_type, is_param_list = self._hparam_types[key]
641 type_str = 'list<%s>' % param_type if is_param_list else str(param_type)
642 fail_msg = ("Hparam '%s' of type '%s' is incompatible with "
643 'default=%s' % (key, type_str, default))
644
645 is_default_list = isinstance(default, list)
646 if is_param_list != is_default_list:
647 raise ValueError(fail_msg)
648
649 try:
650 if is_default_list:
651 for value in default:
652 _cast_to_type_if_compatible(key, param_type, value)
653 else:
654 _cast_to_type_if_compatible(key, param_type, default)
655 except ValueError as e:
656 raise ValueError('%s. %s' % (fail_msg, e))
657
658 return getattr(self, key)
659
660 return default
661
662 def __contains__(self, key):
663 return key in self._hparam_types

Callers 15

testGetMethod · 0.95
testDelMethod · 0.95
ComputeMethod · 0.45
ComputeMethod · 0.45
ComputeMethod · 0.45
AddExampleMethod · 0.45
BestSplitMethod · 0.45
TESTFunction · 0.45
ClassificationStatsMethod · 0.45
BestSplitMethod · 0.45

Calls 1

Tested by 5

testGetMethod · 0.76
testDelMethod · 0.76
TESTFunction · 0.36
TESTFunction · 0.36