2015-10-18 64 views
0

我正在嘗試使用darch包創建幾個堆疊的RBM的dbn。我是深度學習的新手,所以我的問題是:glmnet/randomForest/knn ... etc包中預測函數的等價物是什麼?使用darch預測新樣本類別

訓練完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) 

回答

0

達奇有你可以按照自己的訪問領域一堆getter和setter。執行功能就是其中之一。

對於我來說,最簡單的方法就是做達奇所有層的<- [email protected](darch, inputs)

輸出將在達奇@ executeOutput