You are viewing main version, which requires installation from source. If you'd like
regular pip install, checkout the latest stable version (v0.3.2).
Tensorflow API
safetensors.tensorflow.load_file
< source >( filename: Union ) β Dict[str, tf.Tensor]
Loads a safetensors file into tensorflow format.
safetensors.tensorflow.load
< source >( data: bytes ) β Dict[str, tf.Tensor]
Loads a safetensors file into tensorflow format from pure bytes.
safetensors.tensorflow.save_file
< source >( tensors: Dict filename: Union metadata: Optional = None ) β None
Parameters
- tensors (
Dict[str, tf.Tensor]
) — The incoming tensors. Tensors need to be contiguous and dense. - filename (
str
, oros.PathLike
)) — The filename we’re saving into. - metadata (
Dict[str, str]
, optional, defaults toNone
) — Optional text only metadata you might want to save in your header. For instance it can be useful to specify more about the underlying tensors. This is purely informative and does not affect tensor loading.
Returns
None
Saves a dictionary of tensors into raw bytes in safetensors format.
safetensors.tensorflow.save
< source >( tensors: Dict metadata: Optional = None ) β bytes
Parameters
- tensors (
Dict[str, tf.Tensor]
) — The incoming tensors. Tensors need to be contiguous and dense. - metadata (
Dict[str, str]
, optional, defaults toNone
) — Optional text only metadata you might want to save in your header. For instance it can be useful to specify more about the underlying tensors. This is purely informative and does not affect tensor loading.
Returns
bytes
The raw bytes representing the format
Saves a dictionary of tensors into raw bytes in safetensors format.