torchoutil.serialization.common module¶
- to_builtin( ) str[source]¶
- to_builtin( ) str
- to_builtin( ) str
- to_builtin( ) Dict[str, Any]
- to_builtin(
- x: Tensor,
- *,
- unk_mode: Literal['identity', 'error'] = 'error',
- to_builtin( ) Dict[K, V]
- to_builtin(
- x: DataclassInstance,
- *,
- unk_mode: Literal['identity', 'error'] = 'error',
- to_builtin(
- x: NamedTupleInstance,
- *,
- unk_mode: Literal['identity', 'error'] = 'error',
- to_builtin(
- x: T_BuiltinScalar,
- *,
- unk_mode: Literal['identity', 'error'] = 'error',
- to_builtin( ) Any
Convert an object to a python builtin equivalent.
This function can be used to sanitize data before saving to YAML or CSV file.
- Args:
x: Object to convert to built-in equivalent. unk_mode: When an object type is not recognized, unk_mode defines the behaviour.
If unk_mode == “identity”, the object is returned unchanged. If unk_mode == “error”, a TypeError is raised.