You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by lx...@apache.org on 2017/07/07 15:58:28 UTC
[15/50] [abbrv] incubator-mxnet-test git commit: [R] R >= 3.3.0
(#6840)
[R] R >= 3.3.0 (#6840)
Project: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/commit/52abdabd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/tree/52abdabd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/diff/52abdabd
Branch: refs/heads/master
Commit: 52abdabd919d0c69b962c1926bfb7b9c98652268
Parents: e906f88
Author: Qiang Kou (KK) <qk...@qkou.info>
Authored: Wed Jun 28 16:07:33 2017 -0700
Committer: Eric Junyuan Xie <pi...@users.noreply.github.com>
Committed: Wed Jun 28 16:07:33 2017 -0700
----------------------------------------------------------------------
R-package/DESCRIPTION | 8 ++++----
R-package/R/executor.R | 2 +-
R-package/R/initializer.R | 16 ++++++++--------
R-package/R/model.R | 18 ++++++------------
R-package/R/util.R | 17 -----------------
5 files changed, 19 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/52abdabd/R-package/DESCRIPTION
----------------------------------------------------------------------
diff --git a/R-package/DESCRIPTION b/R-package/DESCRIPTION
index c879c73..fb57b4b 100644
--- a/R-package/DESCRIPTION
+++ b/R-package/DESCRIPTION
@@ -1,10 +1,10 @@
Package: mxnet
Type: Package
-Title: MXNet
+Title: MXNet: A Flexible and Efficient Machine Learning Library for Heterogeneous Distributed Systems
Version: 0.10.1
-Date: 2017-06-02
+Date: 2017-06-27
Author: Tianqi Chen, Qiang Kou, Tong He
-Maintainer: Qiang Kou <qk...@umail.iu.edu>
+Maintainer: Qiang Kou <qk...@qkou.info>
Repository: DMLC
Description: MXNet is a deep learning framework designed for both efficiency
and flexibility. It allows you to mix the flavours of deep learning programs
@@ -28,7 +28,7 @@ Suggests:
rmarkdown,
imager
Depends:
- R (>= 3.2.0)
+ R (>= 3.3.0)
LinkingTo: Rcpp
VignetteBuilder: knitr
RoxygenNote: 5.0.1
http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/52abdabd/R-package/R/executor.R
----------------------------------------------------------------------
diff --git a/R-package/R/executor.R b/R-package/R/executor.R
index f5d773b..d33aeef 100644
--- a/R-package/R/executor.R
+++ b/R-package/R/executor.R
@@ -16,7 +16,7 @@ mx.simple.bind <- function(symbol, ctx, grad.req = "null", ...) {
mx.nd.zeros(shape, ctx)
}, simplify = FALSE, USE.NAMES = TRUE)
grad.reqs <- lapply(names(slist$arg.shapes), function(nm) {
- if (!mx.util.str.endswith(nm, "label") && !mx.util.str.endswith(nm, "data")) {
+ if (!endsWith(nm, "label") && !endsWith(nm, "data")) {
grad.req
} else {
"null"
http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/52abdabd/R-package/R/initializer.R
----------------------------------------------------------------------
diff --git a/R-package/R/initializer.R b/R-package/R/initializer.R
index ab2b151..7a1ffb2 100644
--- a/R-package/R/initializer.R
+++ b/R-package/R/initializer.R
@@ -4,11 +4,11 @@
#' @param shape the shape of the array to be generated.
#'
mx.init.internal.default <- function(name, shape, ctx, allow.unknown=FALSE) {
- if (mx.util.str.endswith(name, "bias")) return (mx.nd.zeros(shape, ctx))
- if (mx.util.str.endswith(name, "gamma")) return (mx.nd.ones(shape, ctx))
- if (mx.util.str.endswith(name, "beta")) return (mx.nd.zeros(shape, ctx))
- if (mx.util.str.endswith(name, "moving_mean")) return (mx.nd.zeros(shape, ctx))
- if (mx.util.str.endswith(name, "moving_var")) return (mx.nd.ones(shape, ctx))
+ if (endsWith(name, "bias")) return (mx.nd.zeros(shape, ctx))
+ if (endsWith(name, "gamma")) return (mx.nd.ones(shape, ctx))
+ if (endsWith(name, "beta")) return (mx.nd.zeros(shape, ctx))
+ if (endsWith(name, "moving_mean")) return (mx.nd.zeros(shape, ctx))
+ if (endsWith(name, "moving_var")) return (mx.nd.ones(shape, ctx))
if (allow.unknown) return(NULL)
stop(paste("Unkown initialization pattern for ", name))
}
@@ -20,7 +20,7 @@ mx.init.internal.default <- function(name, shape, ctx, allow.unknown=FALSE) {
#' @export
mx.init.uniform <- function(scale) {
function(name, shape, ctx, allow.unknown=FALSE) {
- if (!mx.util.str.endswith(name, "weight")) {
+ if (!endsWith(name, "weight")) {
return (mx.init.internal.default(name, shape, ctx, allow.unknown))
}
return (mx.runif(shape, -scale, scale, ctx))
@@ -34,7 +34,7 @@ mx.init.uniform <- function(scale) {
#' @export
mx.init.normal <- function(sd) {
function(name, shape, ctx, allow.unknown=FALSE) {
- if (!mx.util.str.endswith(name, "weight")) {
+ if (!endsWith(name, "weight")) {
return (mx.init.internal.default(name, shape, ctx, allow.unknown))
}
return (mx.rnorm(shape, 0, sd, ctx))
@@ -55,7 +55,7 @@ mx.init.normal <- function(sd) {
mx.init.Xavier <- function(rnd_type = "uniform", factor_type = "avg",
magnitude = 3){
function(name, shape, ctx, allow.unknown = FALSE){
- if (!mx.util.str.endswith(name, "weight")) {
+ if (!endsWith(name, "weight")) {
return (mx.init.internal.default(name, shape, ctx, allow.unknown))
}
http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/52abdabd/R-package/R/model.R
----------------------------------------------------------------------
diff --git a/R-package/R/model.R b/R-package/R/model.R
index ccdd936..069c564 100644
--- a/R-package/R/model.R
+++ b/R-package/R/model.R
@@ -17,14 +17,14 @@ mx.model.check.arguments <- function(symbol) {
data <- NULL
label <- NULL
for (nm in arguments(symbol)) {
- if (mx.util.str.endswith(nm, "data")) {
+ if (endsWith(nm, "data")) {
if (!is.null(data)) {
stop("Multiple fields contains suffix data")
} else {
data <- nm
}
}
- if (mx.util.str.endswith(nm, "label")) {
+ if (endsWith(nm, "label")) {
if (!is.null(label)) {
stop("Multiple fields contains suffix label")
} else {
@@ -106,10 +106,7 @@ mx.model.train <- function(symbol, ctx, input.shape, output.shape,
sliceinfo <- mx.model.slice.shape(input.shape, ndevice)
sliceinfo2 <- mx.model.slice.shape(output.shape, ndevice)
arg_names <- arguments(symbol)
- tmp <- unlist(lapply(arg_names, function(a) {
- mxnet:::mx.util.str.endswith(a, "label")
- }))
- label_name <- arg_names[tmp]
+ label_name <- arg_names[endsWith(arg_names, "label")]
train.execs <- lapply(1:ndevice, function(i) {
arg_lst <- list(symbol = symbol, ctx = ctx[[i]], grad.req = "write",
data=sliceinfo[[i]]$shape)
@@ -271,10 +268,7 @@ mx.model.train <- function(symbol, ctx, input.shape, output.shape,
mx.model.init.params <- function(symbol, input.shape, output.shape, initializer, ctx) {
if (!is.MXSymbol(symbol)) stop("symbol need to be MXSymbol")
arg_names <- arguments(symbol)
- tmp <- unlist(lapply(arg_names, function(a) {
- mxnet:::mx.util.str.endswith(a, "label")
- }))
- label_name <- arg_names[tmp]
+ label_name <- arg_names[endsWith(arg_names, "label")]
arg_lst <- list(symbol = symbol, data=input.shape)
arg_lst[[label_name]] = output.shape
@@ -535,10 +529,10 @@ mx.model.load <- function(prefix, iteration) {
save.dict <- mx.nd.load(sprintf("%s-%04d.params", prefix, iteration))
names <- names(save.dict)
arg.index <- as.integer(mx.util.filter.null(lapply(1:length(names), function(i) {
- if (mx.util.str.startswith(names[[i]], "arg:")) i else NULL
+ if (startsWith(names[[i]], "arg:")) i else NULL
})))
aux.index <- as.integer(mx.util.filter.null(lapply(1:length(names), function(i) {
- if (mx.util.str.startswith(names[[i]], "aux:")) i else NULL
+ if (startsWith(names[[i]], "aux:")) i else NULL
})))
if (length(arg.index) != 0) {
http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/52abdabd/R-package/R/util.R
----------------------------------------------------------------------
diff --git a/R-package/R/util.R b/R-package/R/util.R
index 9eaddf2..2b292d1 100644
--- a/R-package/R/util.R
+++ b/R-package/R/util.R
@@ -1,20 +1,3 @@
-# Internal function to check if name end with suffix
-mx.util.str.endswith <- function(name, suffix) {
- slen <- nchar(suffix)
- nlen <- nchar(name)
- if (slen > nlen) return (FALSE)
- nsuf <- substr(name, nlen - slen + 1, nlen)
- return (nsuf == suffix)
-}
-
-mx.util.str.startswith <- function(name, prefix) {
- slen <- nchar(prefix)
- nlen <- nchar(name)
- if (slen > nlen) return (FALSE)
- npre <- substr(name, 1, slen)
- return (npre == prefix)
-}
-
# filter out null, keep the names
mx.util.filter.null <- function(lst) {
lst[!sapply(lst, is.null)]