MCPcopy Create free account
hub / github.com/SooLab/CGFormer / to_diff_dict

Method to_diff_dict

bert/configuration_utils.py:334–355  ·  view source on GitHub ↗

Removes all attributes from config which correspond to the default config attributes for better readability and serializes to a Python dictionary. Returns: :obj:`Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,

(self)

Source from the content-addressed store, hash-verified

332 return "{} {}".format(self.__class__.__name__, self.to_json_string())
333
334 def to_diff_dict(self):
335 """
336 Removes all attributes from config which correspond to the default
337 config attributes for better readability and serializes to a Python
338 dictionary.
339
340 Returns:
341 :obj:`Dict[str, any]`: Dictionary of all the attributes that make up this configuration instance,
342 """
343 config_dict = self.to_dict()
344
345 # get the default config dict
346 default_config_dict = PretrainedConfig().to_dict()
347
348 serializable_config_dict = {}
349
350 # only serialize values that differ from the default config
351 for key, value in config_dict.items():
352 if key not in default_config_dict or value != default_config_dict[key]:
353 serializable_config_dict[key] = value
354
355 return serializable_config_dict
356
357 def to_dict(self):
358 """

Callers 1

to_json_stringMethod · 0.95

Calls 3

to_dictMethod · 0.95
PretrainedConfigClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected