MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/R/library/OREmodels/doc/man/en/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/R/library/OREmodels/doc/man/en/ore.neural.Rd

%
% Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
%
\name{ore.neural}
\alias{ore.neural}
\alias{predict.ore.neural}
\alias{print.ore.neural}
\alias{coef.ore.neural}
\alias{summary.ore.neural}
\title{Oracle R Enterprise Multilayer Feed-Forward Neural Network Models}
\description{Creates multilayer feed-forward neural network models on
  \code{ore.frame} data.}
\usage{
ore.neural(
    formula,
    data,
    weight         = NULL,
    xlev           = NULL,
    hiddenSizes    = NULL,
    activations    = NULL,
    gradTolerance  = 1E-1,
    maxIterations  = 200L,
    objMinProgress = 1E-6,
    lowerBound     = -0.7,
    upperBound     = 0.7,
    nUpdates       = 20L,
    scaleHessian   = TRUE,
    trace          = getOption("ore.trace", FALSE))

## Specific methods for ore.neural objects
\method{predict}{ore.neural}(object, newdata, supplemental.cols = NULL, ...)
\method{print}{ore.neural}(x, ...)
\method{coef}{ore.neural}(object, ...)
\method{summary}{ore.neural}(object, ...)
}

\arguments{
  \item{ formula }{ A \code{\link[stats]{formula}} object representing the
  neural network model to be trained. }

  \item{ data }{ A \code{ore.frame} object specifying the data for the model. }

  \item{ hiddenSizes }{ An integer vector, whose elements store the number of
  neurons in each hidden layer.  \code{ore.neural} supports an arbitrary number
  of hidden layers.  The length of \code{hiddenSizes} gives the number of
  hidden layers in the model, and \code{hiddenSizes[k]} stores the number of
  neurons in the \code{k}-th hidden layer.  The \code{hiddenSizes} value may be
  \code{NULL}, in which case input units will be directly connected to the
  output neurons (no hidden structure).  If any element of \code{hiddenSizes}
  is zero, then all hidden neurons will be dropped, which is equivalent to
  \code{hiddenSizes=NULL}.

  Example: \code{hiddenSizes=c(10, 4)} specifies a neural network with two
  hidden layers (\code{length(hiddenSizes)} is 2); the first hidden layer will
  have 10 neurons, and the second one will have 4.

  Example: \code{hiddenSizes=c(101, 20, 1)} specifies a neural network with
  three hidden layers, with 101, 20, and 1 units correspondingly.

  In a typical training scenario (assuming no prior knowledge of the model),
  you may start with a single hidden layer and a small number of hidden neurons
  (for instance, \code{hiddenSizes=1}).  You may then gradually increase the
  number of neurons (and possibly layers) until no further error reduction can
  be observed on the validation data set. }

  \item{ activations }{ This argument specifies activation functions for the
  hidden and the output neural network layers.  The \code{ore.neural} function
  supports a single activation function per layer.  Neurons are grouped into
  layers, and each layer (a subset of neurons) can be assigned its own
  activation function.  Note: the target variable range needs to correspond to
  the range of the output activation function.  For instance, logistic sigmoid
  can be used to model targets in the range of zero to one (range of the
  sigmoid function).  The \code{ore.neural} function does not preprocess the
  input data; appropriate data normalization and scaling are strongly
  recommended.

  If the \code{activations} argument is \code{NULL}, then the activation
  function for each hidden layer is bipolar sigmoid and for the output it is
  linear.

  If \code{activations} is not \code{NULL}, then its size must be

  \code{length(hiddenSizes) + 1},

  where the last element corresponds to the output layer.

  Possible values:

\tabular{lll}{
\code{"atan"}          \tab arctangent        \tab \eqn{f(x) = \arctan x                         }\cr
\code{"bSigmoid"}      \tab bipolar sigmoid   \tab \eqn{f(x) = \frac{1 - e^{-x}}{1 + e^{-x}}     }\cr
\code{"cos"}           \tab cosine            \tab \eqn{f(x) = \cos x                            }\cr
\code{"gaussian"}      \tab Gaussian          \tab \eqn{f(x) = e^{-x^2}                          }\cr
\code{"gaussError"}    \tab Gauss error       \tab \eqn{f(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt}\cr
\code{"gompertz"}      \tab Gompertz          \tab \eqn{f(x) = e^{-e^{-x}}                       }\cr
\code{"linear"}        \tab linear            \tab \eqn{f(x) = x                                 }\cr
\code{"reciprocal"}    \tab reciprocal        \tab \eqn{f(x) = \frac{1}{x}                       }\cr
\code{"sigmoid"}       \tab logistic sigmoid  \tab \eqn{f(x) = \frac{1}{1 + e^{-x}}              }\cr
\code{"sigmoidModulus"}\tab sigmoid modulus   \tab \eqn{f(x) = \frac{x}{1 + |x|}                 }\cr
\code{"sigmoidSqrt"}   \tab sigmoid sqrt      \tab \eqn{f(x) = \frac{x}{\sqrt{1 + x^2}}          }\cr
\code{"sin"}           \tab sine              \tab \eqn{f(x) = \sin x                            }\cr
\code{"square"}        \tab square            \tab \eqn{f(x) = x^2                               }\cr
\code{"tanh"}          \tab hyperbolic tangent\tab \eqn{f(x) = \tanh x                           }\cr
\code{"wave"}          \tab wave              \tab \eqn{f(x) = \frac{x}{1 + x^2}                 }\cr
\code{"entropy"}       \tab entropy (output only) \tab \eqn{f(x) = \log(1 + \exp(x)) - yx        }
}

  Example: \code{activations=c("wave", "tanh", "linear")} corresponds to a
  neural network with two hidden layers.  The first hidden layer is assigned
  the \code{"wave"} activation function, the second hidden layer is assigned
  the \code{"tanh"} activation function, and the output (target) layer is
  assigned the \code{"linear"}. }

  \item{ gradTolerance }{ Numerical optimization stopping criterion: Desired
  gradient norm. }

  \item{ maxIterations }{ Numerical optimization stopping criterion: Maximum
  number of iterations. }

  \item{ objMinProgress }{ Numerical optimization stopping criterion: minimal
  relative change in the objective function value. }

  \item{ nUpdates }{ Number of L-BFGS update pairs. }

  \item{ scaleHessian }{ Whether to scale the inverse of the Hessian matrix in
    L-BFGS updates. }

  \item{ lowerBound }{ Lower bound for the weight initialization (not used if
    weights are supplied). }

  \item{ upperBound }{ Upper bound for the weight initialization (not used if
  weights are supplied). }

  \item{ weight }{ Initial vector of weights (may be NULL, in which case a
    random starting point will be generated).  Useful when using a solution
    from a previously solved model.  Note: the previous neural network
    architecture (number of input, output, hidden layers and hidden neurons in
    each layer and the type of activation functions), should be identical to
    the current one. }

  \item{ xlev }{A named \code{\link[base]{list}} of
    \code{\link[base]{character}} vectors specifying the
    \code{\link[base]{levels}} for each
    \code{\link[OREbase:ore.factor-class]{ore.factor}} variable.}

  \item{ trace }{ Report iteration log for the big data (out-of-core) solver. }

  \item{ object, x }{ An \code{ore.neural} object. }
  \item{ newdata }{ An \code{ore.frame} object, test data. }

  \item{ supplemental.cols }{ Additional columns to include in the prediction
  result from the \code{newdata} data set. }

  \item{ \dots }{ Additional arguments. }
}
\value{
  An object of class \code{"ore.neural"}. Some of its components are as follows:
  \item{ weight }{ Weight coefficients. }
  \item{ nLayers }{ Number of layers. }
}

\details{
  The \code{ore.neural} function solves multilayer feed-forward neural network
  models.  It supports an arbitrary number of hidden layers and an arbitrary
  number of neurons per layer.  The L-BFGS algorithm is used to solve the
  underlying unconstrained nonlinear optimization problem.

  The \code{\link[OREbase:ore.options]{"ore.parallel"}} global option is
  used by \code{ore.neural} to determine the preferred degree of
  parallelism to use within the Oracle R Enterprise server.
}

\references{
  Christopher Bishop (1996) \emph{Neural Networks for Pattern Recognition}

  Simon Haykin (2008) \emph{Neural Networks and Learning Machines (3rd
  Edition)}

  Stephen Marsland (2009) \emph{Machine Learning: An Algorithmic Perspective}

  \href{http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/documentation/index.html}{Oracle R Enterprise}
}

\author{
  Oracle \email{oracle-r-enterprise@oracle.com}
}

\seealso{
  \link[OREstats]{model.matrix,formula-method} (\pkg{OREstats} package),
  \code{\link[OREbase:ore.options]{ore.parallel}}
}

\examples{
  ###############################################################
  # Two hidden layers (20 neurons in the first layer, 5 hidden  #
  # neurons in the second layer).                               #
  #                                                             #
  # Use bipolar sigmoid activation function for the first       #
  # hidden layer, hyperbolic tangent for the second hidden      #
  # layer, and linear activation function for the output layer. #
  #                                                             #
  # Note that the dimension (number of elements) of the         #
  # "activations" argument is always greater by exactly one     #
  # than the dimension of "hiddenSizes".                        #
  #                                                             #
  # Least-squares objective function.                           #
  ###############################################################
  IRIS <- ore.push(iris)

  fit <- ore.neural(Petal.Length ~ Petal.Width + Sepal.Length,
    data        = IRIS,
    hiddenSizes = c(20L, 5L),
    activations = c("bSigmoid", "tanh", "linear"))

  ans <- predict(fit, newdata = IRIS,
    supplemental.cols = c("Petal.Length"))

  ###############################################################
  # Entropy objective function.                                 #
  ###############################################################
  INFERT <- ore.push(infert)

  fit <- ore.neural(case ~ ., data = INFERT,
    activations = c('entropy'), objMinProgress = 1E-7)

  # Entropy (max likelihood) model with one hidden layer.
  fit <- ore.neural(
    formula        = case ~ .,
    data           = INFERT,
    hiddenSizes    = c(40L),
    activations    = c("sigmoid", "entropy"),
    lowerBound     = -0.7,
    upperBound     = 0.7,
    objMinProgress = 1E-12,
    maxIterations  = 300L)
}
\keyword{neural}


OHA YOOOO