之前工作用到神经网络拟合nonliear curve
语言用的R语言
找不到源码所以自己参照别人的matlab 代码实现了一个
RBF网络具体介绍见参考文章
参考文章
RBF网络对初始参数设置比较敏感
所以对初始delta 和 center 我利用了kmean 聚类初始化
library(dplyr)
library(data.table)
rbf <- NULL
#Guassian径向基函数
Green <- function(x, c, delta){
greenValue <- exp(-1.0 * sum((x - c)^2) / (2 * delta^2))
}
hiddenSize <- 2
# cols <- 5
# rows <- 7
# train.x <- matrix(runif(cols * rows), ncol = 1)
# train.y <- matrix(runif( cols * rows), ncol = 1)
x <- seq(0,3.14*2, by = 0.01)
y <- sin(x) + runif(length(x))
train.x <- x %>% data.matrix()
train.y <- y %>% data.matrix()
kmeans.parameters <- kmeans(train.x, hiddenSize)
init.centers <- kmeans.parameters$centers
init.delta <- kmeans.parameters$withinss/kmeans.parameters$size + 0.2
rbf$hiddenSize <- hiddenSize
rbf$inputSize <- ncol(train.x)
rbf$outputSize <- ncol(train.y)
rbf