R包DARCH深度信念神经网络无法学习';独占或';看来

R包DARCH深度信念神经网络无法学习';独占或';看来,r,neural-network,deep-learning,R,Neural Network,Deep Learning,提前感谢您的帮助。我正在尝试实现一个深度学习神经网络来预测一些变量(一种多元非线性回归)。作为第一步,我将在R中查看Darch包,并在R中处理代码片段 当我从P10运行下面的代码时,它似乎是在“异或”上训练的,那么生成的神经网络似乎无法学习函数。它要么学习(1,0)模式,要么学习(0,1)模式为真,但不能同时学习两者,有时还会学习(1,1)模式,后者应该为假。我的理解是,这类网络应该能够学习几乎任何功能,包括一开始的“异或”:这不是由最初的反向传播工作解决的,该网络在微调中使用了反向传播工作。

提前感谢您的帮助。我正在尝试实现一个深度学习神经网络来预测一些变量(一种多元非线性回归)。作为第一步,我将在R中查看Darch包,并在R中处理代码片段

当我从P10运行下面的代码时,它似乎是在“异或”上训练的,那么生成的神经网络似乎无法学习函数。它要么学习(1,0)模式,要么学习(0,1)模式为真,但不能同时学习两者,有时还会学习(1,1)模式,后者应该为假。我的理解是,这类网络应该能够学习几乎任何功能,包括一开始的“异或”:这不是由最初的反向传播工作解决的,该网络在微调中使用了反向传播工作。我想我可能错过了什么,所以非常感谢你的建议或帮助?(我甚至将纪元数增加到10000,但没有效果。)

#生成数据集

输入就其价值而言,以下几点对我起了作用:

# Generating the datasets
inputs <- matrix(c(0,0,0,1,1,0,1,1),ncol=2,byrow=TRUE)
print(inputs)

outputs <- matrix(c(0,1,1,0),nrow=4)
print(outputs)


# Generating the darch
darch <- newDArch(c(2,4,1),batchSize=4,ff=F)

# Pre-Train the darch
darch <- preTrainDArch(darch,inputs,maxEpoch=200,numCD=4)

# Prepare the layers for backpropagation training for
# backpropagation training the layer functions must be
# set to the unit functions which calculates the also
# derivatives of the function result.
layers <- getLayers(darch)
for(i in length(layers):1){
  layers[[i]][[2]] <- sigmoidUnitDerivative
}

setLayers(darch) <- layers
rm(layers)

# Setting and running the Fine-Tune function
setFineTuneFunction(darch) <- rpropagation
darch <- fineTuneDArch(darch,trainData=inputs,targetData=outputs,
                       maxEpoch=200,
                       isBin=T)

# Running the darch
darch <- darch <- getExecuteFunction(darch)(darch,inputs)
outputs2 <- getExecOutputs(darch)
cat(outputs2[[length(outputs2)]])
## End(Not run)
#生成数据集

输入I能够在darch中调整基线
example.xor
,以可靠地正确学习简单的xor。以下是基线版本:

> tmp<-mclapply(1:50, function(x) example.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 25 
30 20 
>tmp表格(sapply(tmp,函数(x))尾部(x@stats$dataErrors$class,1)))
0 25 
30 20 
下面是一个经过调整的变体:

trainingData <- matrix(
    c(0,0,
      0,1,
      1,0,
      1,1), ncol=2, byrow=T)
trainingTargets <- matrix(c(0,1,1,0),nrow=4)

tuned.xor <- function() {
    darch(trainingData, trainingTargets,
        # These settings are different
        layers=c(2,6,1),
        darch.batchSize=4,
        darch.fineTuneFunction=function(...) rpropagation(..., weightDecay=0.0001),
        # These settings are all as in example.xor
        darch.bootstrap=F,
        darch.learnRateWeights = 1.0,
        darch.learnRateBiases = 1.0,
        darch.isBin=T,
        darch.stopClassErr=0, 
        darch.numEpochs=1000
    )
}

> tmp<-mclapply(1:50, function(x) tuned.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 
50 

训练数据据我所知,网络是一个前馈感知机。当我读到Hagan、Demith和Beale(1996)的第4-19页时,我读到“感知器可以用来分类输入向量,这些向量可以通过线性边界分离。我们称这些向量为线性可分离的……不幸的是,许多问题不是线性可分离的。经典的例子是XOR门。”
Darch
与w/
h2o
nnet
或其他软件相比,看起来非常复杂,我没有使用它的经验。
Darch
有什么优点吗?非常详细的答案+1深入的学习让人头疼。达奇在深造。使用h2o或多种工具,您可以获得更大的里程数。使用手工工具的木匠每天都能做出漂亮的工作,而不需要电动工具。数据也是如此。imo-如果锤子能工作,不要使用手提钻。这很有道理,有时我们不需要太依赖电动工具。我将尝试使用Darch并了解更多细节:)再次感谢!达奇是杰克·哈默。如果你想要的不是一个坏的中等水平的动力工具,考虑一个随机森林。如果你正在寻找凿子,考虑逻辑回归。我自己,我对“随机森林”或其h2o变化做了很多有益的事情。它相对简单,可以轻松地处理上述逻辑问题。
> tmp<-mclapply(1:50, function(x) example.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 25 
30 20 
trainingData <- matrix(
    c(0,0,
      0,1,
      1,0,
      1,1), ncol=2, byrow=T)
trainingTargets <- matrix(c(0,1,1,0),nrow=4)

tuned.xor <- function() {
    darch(trainingData, trainingTargets,
        # These settings are different
        layers=c(2,6,1),
        darch.batchSize=4,
        darch.fineTuneFunction=function(...) rpropagation(..., weightDecay=0.0001),
        # These settings are all as in example.xor
        darch.bootstrap=F,
        darch.learnRateWeights = 1.0,
        darch.learnRateBiases = 1.0,
        darch.isBin=T,
        darch.stopClassErr=0, 
        darch.numEpochs=1000
    )
}

> tmp<-mclapply(1:50, function(x) tuned.xor())
> table(sapply(tmp,function(x) tail(x@stats$dataErrors$class,1)))

 0 
50