/
hub_load.qmd
45 lines (25 loc) · 1.46 KB
/
hub_load.qmd
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
---
execute:
freeze: true
---
[R/load.R](https://github.com/rstudio/tfhub//blob/main/R/load.R#L34)
# hub_load
## Hub Load
## Description
Loads a module from a handle.
## Usage
```r
hub_load(handle, tags = NULL)
```
## Arguments
|Arguments|Description|
|---|---|
| handle | (string) the Module handle to resolve. |
| tags | A set of strings specifying the graph variant to use, if loading from a v1 module. |
## Details
Currently this method is fully supported only with Tensorflow 2.x and with modules created by calling `export_savedmodel`. The method works in both eager and graph modes. Depending on the type of handle used, the call may involve downloading a TensorFlow Hub module to a local cache location specified by the `TFHUB_CACHE_DIR` environment variable. If a copy of the module is already present in the TFHUB_CACHE_DIR, the download step is skipped. Currently, three types of module handles are supported: 1) Smart URL resolvers such as tfhub.dev, e.g.: https://tfhub.dev/google/nnlm-en-dim128/1. 2) A directory on a file system supported by Tensorflow containing module files. This may include a local directory (e.g. /usr/local/mymodule) or a Google Cloud Storage bucket (gs://mymodule). 3) A URL pointing to a TGZ archive of a module, e.g. https://example.com/mymodule.tar.gz.
## Examples
```{r, eval=ecodown::examples_not_run()}
library(tfhub)
model <- hub_load('https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4')
```