我在R语言中使用Caret包,尝试实现多层感知器来对卫星图像进行分类。我使用了method=mlpML
,我想知道使用的是哪种激活函数。
这是我的代码:
controlparameters<-trainControl(method = "repeatedcv", number=5, repeats = 5, savePredictions=TRUE, classProbs = TRUE)mlp_grid<-expand.grid(layer1=13, layer2=0, layer3=0)model< train(as.factor(Species)~., data = smotedata, method='mlpML', preProc = c('center', 'scale'), trcontrol=controlparameters, tuneGrid=mlp_grid, importance=T)
我使用了单层,因为它的表现比多层更好。
回答:
查看Caret的源代码中关于mlpML
的部分,发现它使用的是RSNNS包中的mlp
函数。
根据RSNNS的mlp
文档,其默认参数是:
mlp(x, ...)## Default S3 method:mlp(x, y, size = c(5), maxit = 100, initFunc = "Randomize_Weights", initFuncParams = c(-0.3, 0.3), learnFunc = "Std_Backpropagation", learnFuncParams = c(0.2, 0), updateFunc = "Topological_Order", updateFuncParams = c(0), hiddenActFunc = "Act_Logistic", shufflePatterns = TRUE, linOut = FALSE, outputActFunc = if (linOut) "Act_Identity" else "Act_Logistic", inputsTest = NULL, targetsTest = NULL, pruneFunc = NULL, pruneFuncParams = NULL, ...)
由此可见,hiddenActFunc = "Act_Logistic"
,即隐藏层的激活函数是逻辑函数。