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)
| 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 | """ |
no test coverage detected