File size: 774 Bytes
fe8e241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
args <- commandArgs(trailingOnly = FALSE)
script_arg <- grep("^--file=", args, value = TRUE)
if (length(script_arg) > 0) {
  script_path <- normalizePath(sub("^--file=", "", script_arg[1]))
  setwd(normalizePath(file.path(dirname(script_path), "..")))
}

library(reticulate)
use_python(Sys.getenv("RETICULATE_PYTHON"), required = TRUE)
np <- import("numpy", convert = FALSE)

encoded <- readRDS("model/GAN/seq_all_encoded.RDS")
names_encoded <- names(encoded)

for (i in seq_along(encoded)) {
  out_file <- sprintf("model/GAN/seq_encoded_%02d.npz", i)
  np$savez_compressed(
    out_file,
    x = np$array(encoded[[i]], dtype = "float32"),
    name = names_encoded[[i]]
  )
  cat("saved", out_file, names_encoded[[i]], dim(encoded[[i]]), "\n")
}

cat("export GAN npz OK\n")