MINI MINI MANI MO
%
% 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 多层前馈神经网络模型
}
\description{
在 \code{ore.frame} 数据上创建多层前馈神经网络
模型。
}
\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 }{
\code{\link[stats]{formula}} 对象表示要培训的
神经网络模型。
}
\item{ data }{
一个用于指定模型数据的 \code{ore.frame} 对象。
}
\item{ hiddenSizes }{
一个内部向量, 其元素存储各个隐藏层中的
神经元数。\code{ore.neural} 支持任意数量的
隐藏层。\code{hiddenSizes} 的长度提供了模型中
隐藏层的数量, \code{hiddenSizes[k]} 存储第 \code{k} 个隐藏层中
神经元的数量。\code{hiddenSizes} 值可以为
\code{NULL}, 这时输入单元将直接连接到
输出神经元 (无隐藏结构)。如果 \code{hiddenSizes} 的任何元素
为零, 则将删除所有隐藏神经元, 这等同于
\code{hiddenSizes=NULL}。
示例: \code{hiddenSizes=c(10, 4)} 指定有两个隐藏层的
神经网络 (\code{length(hiddenSizes)} 为 2); 第一个隐藏层
有 10 个神经元, 第二个隐藏层有 4 个。
示例: \code{hiddenSizes=c(101, 20, 1)} 指定有三个隐藏层的
神经网络, 分别有 101, 20 和 1 个单元。
在典型培训方案中 (假定没有模型的先验指示),
则可以通过一个隐藏层和较少数量的隐藏神经元
开始, (例如, \code{hiddenSizes=1})。然后, 可以逐步增加
神经元的数量 (也可以增加层), 直至在验证数据集上
再也观察不到更多的误差减少。
}
\item{ activations }{
此参数指定隐藏和输出神经网络层的
激活函数。\code{ore.neural} 函数
支持每个层一个激活函数。神经元分组到
层中, 每个层 (神经元的子集) 可以分配自身的
激活函数。注: 目标变量范围需要与输出
激活函数的范围对应。例如, 逻辑 sigmoid
可用于在范围零到一之间 (sigmoid 函数的范围)
建模目标。\code{ore.neural} 函数不预处理
输入数据; 强烈建议进行合适的数据规范化
和定标。
如果 \code{activations} 参数为 \code{NULL}, 则每个隐藏层的
激活函数为双极 sigmoid, 输出的激活函数为
线性。
如果 \code{activations} 不是 \code{NULL}, 则其大小必须为
\code{length(hiddenSizes) + 1},
其中最后一个元素对应于输出层。
可能值:
\tabular{lll}{
\code{"atan"} \tab 反正切 \tab \eqn{f(x) = \\arctan x }\cr
\code{"bSigmoid"} \tab 双极性 sigmoid \tab \eqn{f(x) = \\frac{1 - e^{-x}}{1 + e^{-x}} }\cr
\code{"cos"} \tab 余弦 \tab \eqn{f(x) = \\cos x }\cr
\code{"gaussian"} \tab 高斯 \tab \eqn{f(x) = e^{-x^2} }\cr
\code{"gaussError"} \tab 高斯误差 \tab \eqn{f(x) = \\frac{2}{\\sqrt{\\pi}} \\int_0^x e^{-t^2} dt}\cr
\code{"gompertz"} \tab 龚帕兹 \tab \eqn{f(x) = e^{-e^{-x}} }\cr
\code{"linear"} \tab 线性 \tab \eqn{f(x) = x }\cr
\code{"reciprocal"} \tab 倒数 \tab \eqn{f(x) = \\frac{1}{x} }\cr
\code{"sigmoid"} \tab 逻辑 sigmoid \tab \eqn{f(x) = \\frac{1}{1 + e^{-x}} }\cr
\code{"sigmoidModulus"}\tab sigmoid 模数 \tab \eqn{f(x) = \\frac{x}{1 + |x|} }\cr
\code{"sigmoidSqrt"} \tab sigmoid 平方根 \tab \eqn{f(x) = \\frac{x}{\\sqrt{1 + x^2}} }\cr
\code{"sin"} \tab 正弦 \tab \eqn{f(x) = \\sin x }\cr
\code{"square"} \tab 平方 \tab \eqn{f(x) = x^2 }\cr
\code{"tanh"} \tab 双曲正切\tab \eqn{f(x) = \\tanh x }\cr
\code{"wave"} \tab 波 \tab \eqn{f(x) = \\frac{x}{1 + x^2} }\cr
\code{"entropy"} \tab 熵 (仅输出) \tab \eqn{f(x) = \\log(1 + \\exp(x)) - yx }
}
示例: \code{activations=c("wave", "tanh", "linear")} 对应于
有两个隐藏层的神经网络。第一个隐藏层分配了
\code{"wave"} 激活函数, 第二个隐藏层分配了
\code{"tanh"} 激活函数, 输出 (目标) 层
分配了 \code{"linear"}。
}
\item{ gradTolerance }{
数值优化停止标准: 所需
梯度范数。
}
\item{ maxIterations }{
数值优化停止标准: 最大
迭代数。
}
\item{ objMinProgress }{
数值优化停止标准: 目标函数值
中的最小相对更改。
}
\item{ nUpdates }{
L-BFGS 更新对的数量。
}
\item{ scaleHessian }{
是否在 L-BFGS 更新中扩展 Hessian 矩阵的
求逆。
}
\item{ lowerBound }{
权重初始化的下限 (如果提供了
权重则不使用)。
}
\item{ upperBound }{
权重初始化的上限 (如果提供了
权重则不使用)。
}
\item{ weight }{
权重的初始向量 (可以为 NULL, 这时将生成
随机起始点)。在使用来自以前解析的模型
中的解决方案时, 这非常有用。注: 以前的神经网络
体系结构 (各层中的输入数, 输出数, 隐藏层数量和
隐藏神经元数量, 以及激活函数的类型), 应与
当前的相同。
}
\item{ xlev }{
用于为每个
\code{\link[base]{list}} 变量指定 \code{\link[base]{character}} 的
\code{\link[base]{levels}} 向量的
指定 \code{\link[OREbase:ore.factor-class]{ore.factor}}。
}
\item{ trace }{
大数据 (核心外) 解析器的报告迭代对数。
}
\item{ object, x }{
一个 \code{ore.neural} 对象。
}
\item{ newdata }{
\code{ore.frame} 对象, 测试数据。
}
\item{ supplemental.cols }{
来自 \code{newdata} 数据集要包括在预测结果中的
附加列。
}
\item{ \dots }{
附加参数。
}
}
\value{
类 \code{"ore.neural"} 的对象。其部分组件如下所示:
\item{ weight }{权重系数。}
\item{ nLayers }{层数。}
}
\details{
\code{ore.neural} 函数解析多层前馈神经网络
模型。它支持任意数量的隐藏层和
每层任意数量的神经元。L-BFGS 算法用于解析
底层无限制非线性优化问题。
\code{\link[OREbase:ore.options]{"ore.parallel"}} 使用 \code{ore.neural} 全局选项来
确定要在 Oracle R Enterprise 服务器中使用的
首选并行度。
}
\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