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")