Skip to content

Commit

Permalink
Last changes for release 0.12.0
Browse files Browse the repository at this point in the history
- change order of darch() function definitions to provide more
  reasonable parameter ordering
- bump version number and date
- add autoencoder example
  • Loading branch information
saviola777 committed May 22, 2016
1 parent cae3ab2 commit b85978e
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 92 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
^\.gitignore$
^\.git$
^DARCH_CANCEL_?$
README\.md
README\.md
^tests$
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.Rproj.user
.Rhistory
.Renviron
.RData
.gitignore~
*.Rout
Expand All @@ -9,3 +10,6 @@ data/
helper/
benchmarks/
logs/
local/
tests/

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: darch
Type: Package
Title: Package for Deep Architectures and Restricted Boltzmann Machines
Version: 0.11.9000
Date: 2016-01-13
Version: 0.12.0
Date: 2016-05-22
Author: Martin Drees [aut, cre, cph],
Johannes Rueckert [ctb],
Christoph M. Friedrich [ctb],
Expand Down
95 changes: 47 additions & 48 deletions R/darch.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,54 +81,6 @@ darch <- function(x, ...)
UseMethod("darch")
}


#' @param data \code{\link{data.frame}} containing the dataset, if \code{x} is
#' a \code{\link{formula}}.
#' @rdname darch
#' @export
darch.formula <- function(x, data, layers, ..., xValid=NULL,
dataSet = NULL, dataSetValid = NULL, logLevel = NULL, paramsList = list(),
darch = NULL)
{
oldLogLevel <- futile.logger::flog.threshold()
on.exit(futile.logger::flog.threshold(oldLogLevel))
setLogLevel(logLevel)

if (is.null(dataSet))
{
# Use existing DataSet if available
# TODO check if formula fit?
if (!is.null(darch))
{
dataSet <- createDataSet(data = data,
targets = NULL, dataSet = darch@dataSet)
}
else
{
dataSet <- createDataSet(data = data, formula = x, ...)
}
}

if (is.null(dataSetValid) && !is.null(xValid))
{
dataSetValid <- createDataSet(xValid, T, previous.dataSet = dataSet,
...)
}

darch <- darch(dataSet, dataSetValid = dataSetValid, ...,
layers = if (missing(layers)) 10 else layers, paramsList = paramsList,
darch = darch)

darch
}

#' @rdname darch
#' @export
darch.DataSet <- function(x, ...)
{
darch.default(x = NULL, y = NULL, ..., dataSet = x)
}

#' @param x Input data matrix or \code{\link{data.frame}}
#' (\code{darch.default}) or \code{\link{formula}} (\code{darch.formula}) or
#' \code{\linkS4class{DataSet}} (\code{darch.DataSet}).
Expand Down Expand Up @@ -574,3 +526,50 @@ darch.default <- function(

darch
}

#' @param data \code{\link{data.frame}} containing the dataset, if \code{x} is
#' a \code{\link{formula}}.
#' @rdname darch
#' @export
darch.formula <- function(x, data, layers, ..., xValid=NULL,
dataSet = NULL, dataSetValid = NULL, logLevel = NULL, paramsList = list(),
darch = NULL)
{
oldLogLevel <- futile.logger::flog.threshold()
on.exit(futile.logger::flog.threshold(oldLogLevel))
setLogLevel(logLevel)

if (is.null(dataSet))
{
# Use existing DataSet if available
# TODO check if formula fit?
if (!is.null(darch))
{
dataSet <- createDataSet(data = data,
targets = NULL, dataSet = darch@dataSet)
}
else
{
dataSet <- createDataSet(data = data, formula = x, ...)
}
}

if (is.null(dataSetValid) && !is.null(xValid))
{
dataSetValid <- createDataSet(xValid, T, previous.dataSet = dataSet,
...)
}

darch <- darch(dataSet, dataSetValid = dataSetValid, ...,
layers = if (missing(layers)) 10 else layers, paramsList = paramsList,
darch = darch)

darch
}

#' @rdname darch
#' @export
darch.DataSet <- function(x, ...)
{
darch.default(x = NULL, y = NULL, ..., dataSet = x)
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install_github("maddin79/[email protected]")
```


Then, use `?darch` to view its documentation or `example("darch")` to load some examples (these will not directly be executed, but provide `example.*` functions).
Then, use `?darch` to view its documentation or `example("darch")` to view some simple examples.

### About

Expand Down
11 changes: 11 additions & 0 deletions examples/example.autoencoder.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
example.autoencoder <- function(...)
{
data(iris)
darch <- darch(iris[,1:4], iris[,1:4], c(4,100,2,100,4), darch.isClass = F,
preProc.params = list(method = c("center", "scale")), preProc.targets = T,
darch.numEpochs = 200, darch.batchSize = 3,
darch.unitFunction = softplusUnit, bp.learnRate = .1,
darch.fineTuneFunction = "backpropagation")

predict(darch, newdata = iris[,1:4])
}
2 changes: 1 addition & 1 deletion examples/examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ plot(model2)

#
# More examples can be found at
# https://github.com/maddin79/darch/tree/master/examples/
# https://github.com/maddin79/darch/tree/v0.12.0/examples
74 changes: 35 additions & 39 deletions man/darch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b85978e

Please sign in to comment.