MCPcopy
hub / github.com/tensorflow/models / as_dict

Method as_dict

official/modeling/hyperparams/oneof.py:32–45  ·  view source on GitHub ↗

Returns a dict representation of OneOfConfig. For the nested base_config.Config, a nested dict will be returned.

(self)

Source from the content-addressed store, hash-verified

30 type: Optional[str] = None
31
32 def as_dict(self):
33 """Returns a dict representation of OneOfConfig.
34
35 For the nested base_config.Config, a nested dict will be returned.
36 """
37 if self.type is None:
38 return {'type': None}
39 elif self.__dict__['type'] not in self.__dict__:
40 raise ValueError('type: {!r} is not a valid key!'.format(
41 self.__dict__['type']))
42 else:
43 chosen_type = self.type
44 chosen_value = self.__dict__[chosen_type]
45 return {'type': self.type, chosen_type: self._export_config(chosen_value)}
46
47 def get(self):
48 """Returns selected config based on the value of type.

Callers 15

build_learning_rateMethod · 0.45
build_optimizerMethod · 0.45
test_to_dictMethod · 0.45
test_get_oneofMethod · 0.45
_get_params_from_flagsFunction · 0.45
train_and_evalFunction · 0.45
exportFunction · 0.45
runFunction · 0.45
__init__Method · 0.45
get_configMethod · 0.45
get_configMethod · 0.45

Calls 1

_export_configMethod · 0.80

Tested by 15

test_to_dictMethod · 0.36
test_get_oneofMethod · 0.36
test_configsMethod · 0.36
test_nhnet_configMethod · 0.36
setUpMethod · 0.36