safe_save_file | R Documentation |
Writes a list of tensors to the safetensors format
safe_save_file(tensors, path, ..., metadata = NULL)
safe_serialize(tensors, ..., metadata = NULL)
tensors |
A named list of tensors. Currently only torch tensors are supported. |
path |
The path to save the tensors to. It can also be a binary connection, as eg,
created with |
... |
Currently unused. |
metadata |
An optional string that is added to the file header. Possibly adding additional description to the weights. |
The path invisibly or a raw vector.
safe_serialize()
: Serializes the tensors and returns a raw vector.
if (rlang::is_installed("torch") && torch::torch_is_installed()) {
tensors <- list(x = torch::torch_randn(10, 10))
temp <- tempfile()
safe_save_file(tensors, temp)
safe_load_file(temp)
ser <- safe_serialize(tensors)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.