使用darch预测新的样本类

时间:2015-10-18 05:25:56

标签: r deep-learning predict

我正在尝试使用darch包来创建几个堆叠RBM的dbn。我是深度学习场景的新手,所以我的问题是:glmnet / randomForest / knn ... etc包中的预测函数等价于什么?

训练dbn后,如何预测外部样本?例如(这是包中提供的示例)

## Not run:
# Generating the datasets
inputs <- matrix(c(0,0,0,1,1,0,1,1),ncol=2,byrow=TRUE)
outputs <- matrix(c(0,1,1,0),nrow=4)
# Generating the darch
darch <- newDArch(c(2,4,1),batchSize=2)
# Pre-Train the darch
darch <- preTrainDArch(darch,inputs,maxEpoch=1000)
# 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) <- backpropagation
darch <- fineTuneDArch(darch,inputs,outputs,maxEpoch=1000)
# Running the darch
darch <- darch <- getExecuteFunction(darch)(darch,inputs)
outputs <- getExecOutputs(darch)
cat(outputs[[length(outputs)]])

现在假设我们有

inputsTest <- matrix(c(0,1,0,0,0,0,1,1),ncol=2,byrow=TRUE)

如何获得输出?

另外,有人可以解释这一行的作用:

darch <- darch <- getExecuteFunction(darch)(darch,inputs)

1 个答案:

答案 0 :(得分:0)

实际上,这确实很有帮助,有一个直接的预测命令。 https://github.com/maddin79/darch