1

R我想通过使用RSNNS包来适应循环神经网络。该包提供了设置最大迭代次数的选项,如下面的示例代码中所做的那样maxit = 1000。是否可以查看算法在收敛之前使用了多少次迭代?

library(RSNNS)
library(xts)

#Load Lynx data
data(lynx)

#Scale data and convert to xts
data  <- as.xts((lynx - min(lynx)) / (max(lynx) - min(lynx)))

#Build xts object with 5 lags to analyze
lags <- 5
for(i in 1:lags){

  feat <- lag(lynx, i)
  data <- merge(data, feat, all = FALSE)

}

#Get features and target
features <- data[,-1]
target   <- data[,1]

#Fit network
rnn      <- elman(features, target, maxit = 1000)
4

1 回答 1

1

我认为它默认运行最大迭代次数。当您运行以下命令时,即使在图表中处于稳定状态后,迭代也会继续。

rnn <- elman(features, target, maxit = 1000)
plotIterativeError(rnn)

#then run this
rnn <- elman(features, target, maxit = 10000)
plotIterativeError(rnn)

您可能可以使用head(which(abs(diff(rnn$IterativeFitError)) < 1e-20), 1)它来找到收敛时的迭代步骤。

于 2016-04-21T00:05:47.223 回答