【问题标题】:Get number of iterations until convergence in R's RSNNS package在 R 的 RSNNS 包中获取迭代次数直到收敛
【发布时间】:2016-08-13 00:02:07
【问题描述】:

我想通过使用RSNNSpackage 在R 中拟合一个循环神经网络。该包提供了设置最大迭代次数的选项,正如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)

【问题讨论】:

    标签: r neural-network recurrent-neural-network


    【解决方案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)) &lt; 1e-20), 1)来找到收敛时的迭代步。

    【讨论】:

    • 如果满足错误条件,有没有办法让函数停止?
    • 如果我没记错的话,它会调用内部 C 代码。您可以在控制台中打印该功能并进行检查。如果是,则需要更改 C 代码并重新编译。
    猜你喜欢
    • 1970-01-01
    • 2019-03-11
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 2017-05-20
    • 2019-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多