Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix mx.nd.load
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiang Kou committed Nov 14, 2015
1 parent 7c5feb2 commit a503f4b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions R-package/R/ndarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
#' @export
mx.nd.load <- function(filename) {
filename <- path.expand(filename)
ndarray <- mx.nd.internal.load(filename)
if (length(ndarray) == 1) {
return(ndarray[[1]])
} else {
return(ndarray)
}
return(mx.nd.internal.load(filename))
}

#' Save an mx.nd.array object
Expand All @@ -30,7 +25,7 @@ mx.nd.load <- function(filename) {
#' mx.nd.save(mat, 'temp.mat')
#' mat2 = mx.nd.load('temp.mat')
#' as.array(mat)
#' as.array(mat2)
#' as.array(mat2[[1]])
#'
#' @export
mx.nd.save <- function(ndarray, filename) {
Expand Down
4 changes: 2 additions & 2 deletions R-package/tests/testthat/test_ndarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ test_that("ndarray ones, zeros, save and load", {
mat = mx.nd.array(1:20)
mx.nd.save(mat, 'temp.mat')
mat2 = mx.nd.load('temp.mat')
expect_true(is.mx.ndarray(mat2))
expect_equal(as.array(mat), as.array(mat2))
expect_true(is.mx.ndarray(mat2[[1]]))
expect_equal(as.array(mat), as.array(mat2[[1]]))
})
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ model = mx.model.load("Inception/Inception_BN", iteration=39)
We also need to load in the mean image, which is used for preprocessing using ```mx.nd.load```.

```{r}
mean.img = as.array(mx.nd.load("Inception/mean_224.nd"))
mean.img = as.array(mx.nd.load("Inception/mean_224.nd")[["mean_img"]])
```

Load and Preprocess the Image
Expand Down
2 changes: 1 addition & 1 deletion R-package/vignettes/ndarrayAndSymbolTutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ You can also load it back easily:

```{r}
a <- mx.nd.load("temp.ndarray")
as.array(a)
as.array(a[[1]])
```

In case you want to save data to the distributed file system such as S3 and HDFS,
Expand Down

0 comments on commit a503f4b

Please sign in to comment.