-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
61 lines (43 loc) · 1.2 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# safetensors
<!-- badges: start -->
[![R-CMD-check](https://github.com/mlverse/safetensors/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mlverse/safetensors/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
safetensors is a pure R implementation of the [safetensors](https://github.com/huggingface/safetensors) file format.
Currently only reading files is supported.
## Installation
safetensors can be installed from CRAN with:
``` r
install.packages("safetensors")
```
The development version of safetensors from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("mlverse/safetensors")
```
## Example
Here's an example of writing and reading safetensors files:
```{r}
library(torch)
library(safetensors)
tensors <- list(
x = torch_randn(10, 10),
y = torch_ones(10, 10)
)
str(tensors)
tmp <- tempfile()
safe_save_file(tensors, tmp)
tensors <- safe_load_file(tmp)
str(tensors)
```