File size: 1,038 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)

save_npz <- function(out_file, x_train, y_train, x_test, y_test) {
  np$savez_compressed(
    out_file,
    x_train = np$array(readRDS(x_train), dtype = "float32"),
    y_train = np$array(readRDS(y_train), dtype = "float32"),
    x_test  = np$array(readRDS(x_test),  dtype = "float32"),
    y_test  = np$array(readRDS(y_test),  dtype = "float32")
  )
}

save_npz("model/CNN/c1_data.npz", "model/CNN/c1_train.RDS", "model/CNN/c1_train_y.RDS", "model/CNN/c1_test.RDS", "model/CNN/c1_test_y.RDS")
save_npz("model/CNN/p1_data.npz", "model/CNN/p1_train.RDS", "model/CNN/p1_train_y.RDS", "model/CNN/p1_test.RDS", "model/CNN/p1_test_y.RDS")

cat("export cnn npz OK\n")