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

Commit

Permalink
fix epoch and batch naming
Browse files Browse the repository at this point in the history
  • Loading branch information
hetong007 committed Oct 29, 2015
1 parent 8d0ef5d commit a1f8ce7
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 19 deletions.
3 changes: 3 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ export(mx.model.FeedForward.create)
export(mx.model.load)
export(mx.model.save)
export(mx.nd.array)
export(mx.nd.choose.element)
export(mx.nd.clip)
export(mx.nd.copyto)
export(mx.nd.dot)
export(mx.nd.load)
export(mx.nd.ones)
export(mx.nd.save)
export(mx.nd.sqrt)
export(mx.nd.square)
export(mx.nd.zeros)
export(mx.opt.create)
export(mx.opt.get.updater)
Expand Down
18 changes: 9 additions & 9 deletions R-package/R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ mx.model.train <- function(symbol, ctx, input.shape,
begin.round, end.round, optimizer,
train.data, eval.data,
metric,
iter.end.callback,
epoch.end.callback,
batch.end.callback,
kvstore) {
ndevice <- length(ctx)
cat(paste0("Start training with ", ndevice, " devices\n"))
Expand Down Expand Up @@ -195,8 +195,8 @@ mx.model.train <- function(symbol, ctx, input.shape,
}
}
nbatch <- nbatch + 1
if (!is.null(epoch.end.callback)) {
epoch.end.callback(iteration, nbatch, environment())
if (!is.null(batch.end.callback)) {
batch.end.callback(iteration, nbatch, environment())
}
}
# reset training data
Expand Down Expand Up @@ -244,8 +244,8 @@ mx.model.train <- function(symbol, ctx, input.shape,
}
# get the model out
model <- mx.model.extract.model(symbol, train.execs)
if (!is.null(iter.end.callback)) {
iter.end.callback(iteration, 0, environment())
if (!is.null(epoch.end.callback)) {
epoch.end.callback(iteration, 0, environment())
}
}
return(model)
Expand Down Expand Up @@ -355,9 +355,9 @@ mx.model.select.layout.predict <- function(X, model) {
#' The validation set used for validation evaluation during the progress
#' @param eval.metric function, optional
#' The evaluation function on the results.
#' @param iter.end.callback function, optional
#' The callback when iteration ends.
#' @param epoch.end.callback function, optional
#' The callback when iteration ends.
#' @param batch.end.callback function, optional
#' The callback when one mini-batch iteration ends.
#' @param array.batch.size integer (default=128)
#' The batch size used for R array training.
Expand All @@ -377,7 +377,7 @@ function(symbol, X, y=NULL, ctx=NULL,
num.round=10, optimizer="sgd",
initializer=mx.init.uniform(0.01),
eval.data=NULL, eval.metric=NULL,
iter.end.callback=NULL, epoch.end.callback=NULL,
epoch.end.callback=NULL, batch.end.callback=NULL,
array.batch.size=128, array.layout="auto",
kvstore="local",
...) {
Expand Down Expand Up @@ -413,8 +413,8 @@ function(symbol, X, y=NULL, ctx=NULL,
1, num.round, optimizer=optimizer,
train.data=X, eval.data=eval.data,
metric=eval.metric,
iter.end.callback=iter.end.callback,
epoch.end.callback=epoch.end.callback,
batch.end.callback=batch.end.callback,
kvstore=kvstore)
return (model)
}
Expand Down
2 changes: 1 addition & 1 deletion R-package/demo/basic_convnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ model <- mx.model.FeedForward.create(softmax, X=dtrain, eval.data=dtest,
ctx=devices, num.round=1,
learning.rate=0.1, momentum=0.9,
initializer=mx.init.uniform(0.07),
epoch.end.callback=mx.callback.log.train.metric(100))
batch.end.callback=mx.callback.log.train.metric(100))

4 changes: 2 additions & 2 deletions R-package/demo/basic_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ model <- mx.model.FeedForward.create(softmax, X=dtrain, eval.data=dtest,
ctx=devices, num.round=1,
learning.rate=0.1, momentum=0.9,
initializer=mx.init.uniform(0.07),
iter.end.callback=mx.callback.save.checkpoint("chkpt"),
epoch.end.callback=mx.callback.log.train.metric(100))
epoch.end.callback=mx.callback.save.checkpoint("chkpt"),
batch.end.callback=mx.callback.log.train.metric(100))

# do prediction
pred <- predict(model, dtest)
Expand Down
2 changes: 1 addition & 1 deletion R-package/demo/basic_training.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ model <- mx.model.FeedForward.create(softmax, X=X, y=y,
ctx=devices, num.round=1,
learning.rate=0.1, momentum=0.9,
initializer=mx.init.uniform(0.07),
epoch.end.callback=mx.callback.log.train.metric(100))
batch.end.callback=mx.callback.log.train.metric(100))
17 changes: 12 additions & 5 deletions R-package/man/mx.model.FeedForward.create.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
\usage{
mx.model.FeedForward.create(symbol, X, y = NULL, ctx = NULL,
num.round = 10, optimizer = "sgd", initializer = mx.init.uniform(0.01),
eval.data = NULL, eval.metric = NULL, iter.end.callback = NULL,
epoch.end.callback = NULL, array.batch.size = 128, kvstore = "local",
...)
eval.data = NULL, eval.metric = NULL, epoch.end.callback = NULL,
batch.end.callback = NULL, array.batch.size = 128,
array.layout = "auto", kvstore = "local", ...)
}
\arguments{
\item{symbol}{The symbolic configuration of the neural network.}
Expand Down Expand Up @@ -37,15 +37,22 @@ The validation set used for validation evaluation during the progress}
\item{eval.metric}{function, optional
The evaluation function on the results.}

\item{iter.end.callback}{function, optional
\item{epoch.end.callback}{function, optional
The callback when iteration ends.}

\item{epoch.end.callback}{function, optional
\item{batch.end.callback}{function, optional
The callback when one mini-batch iteration ends.}

\item{array.batch.size}{integer (default=128)
The batch size used for R array training.}

\item{array.layout}{can be "auto", "colmajor", "rowmajor", (detault=auto)
The layout of array. "rowmajor" is only supported for two dimensional array.
For matrix, "rowmajor" means dim(X) = c(nexample, nfeatures),
"colmajor" means dim(X) = c(nfeatures, nexample)
"auto" will auto detect the layout by match the feature size,
and will report error when X is a square matrix to ask user to explicitly specify layout.}

\item{kvstore}{string (default="local")
The parameter synchronization scheme in multiple devices.}
}
Expand Down
19 changes: 19 additions & 0 deletions R-package/man/mx.nd.choose.element.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mxnet_generated.R
\name{mx.nd.choose.element}
\alias{mx.nd.choose.element}
\title{Choose one element from each line(row for python, column for R/Julia) in lhs according to index indicated by rhs}
\arguments{
\item{lhs}{NDArray
Left operand to the function.}

\item{rhs}{NDArray
Right operand to the function.}
}
\value{
out The result mx.ndarray
}
\description{
Choose one element from each line(row for python, column for R/Julia) in lhs according to index indicated by rhs
}

16 changes: 16 additions & 0 deletions R-package/man/mx.nd.sqrt.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mxnet_generated.R
\name{mx.nd.sqrt}
\alias{mx.nd.sqrt}
\title{Take square root of the src}
\arguments{
\item{src}{NDArray
Source input to the function.}
}
\value{
out The result mx.ndarray
}
\description{
Take square root of the src
}

16 changes: 16 additions & 0 deletions R-package/man/mx.nd.square.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mxnet_generated.R
\name{mx.nd.square}
\alias{mx.nd.square}
\title{Take square of the src}
\arguments{
\item{src}{NDArray
Source input to the function.}
}
\value{
out The result mx.ndarray
}
\description{
Take square of the src
}

9 changes: 8 additions & 1 deletion R-package/man/predict.MXFeedForwardModel.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\title{Predict the outputs given a model and dataset.}
\usage{
\method{predict}{MXFeedForwardModel}(model, X, ctx = NULL,
array.batch.size = 128)
array.batch.size = 128, array.layout = "auto")
}
\arguments{
\item{model}{The MXNet Model.}
Expand All @@ -15,6 +15,13 @@
\item{ctx}{mx.cpu() or mx.gpu(i) The device used to generate the prediction.}

\item{array.batch.size}{The batch size used in batching. Only used when X is R's array.}
\item{array.layout}{can be "auto", "colmajor", "rowmajor", (detault=auto)
The layout of array. "rowmajor" is only supported for two dimensional array.
For matrix, "rowmajor" means dim(X) = c(nexample, nfeatures),
"colmajor" means dim(X) = c(nfeatures, nexample)
"auto" will auto detect the layout by match the feature size,
and will report error when X is a square matrix to ask user to explicitly specify layout.}
}
\description{
Predict the outputs given a model and dataset.
Expand Down

0 comments on commit a1f8ce7

Please sign in to comment.