尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

完整教程:Deep Learning|01 RBF Network

完整教程:Deep Learning|01 RBF Network
📅 发布时间:2026/6/20 6:54:02

Deep Learning|01 RBF Network

文章目录

  • Deep Learning|01 RBF Network
    • Radial Basis Function Interpolation, RBF Interpolation
    • RBF Network
    • How to build a simple RBF network?

Radial Basis Function Interpolation, RBF Interpolation

Radial basis functions are a class of real-valued functions that depend solely on the radial distance between the input vector and a fixed center point. Their core characteristic is that the function value is independent of the direction of the input and only related to the distance from the input to the center point.

Let Φ(x)\Phi (x)Φ(x)is a RBF , for any input vectorx\boldsymbol{x}x, and center vectorsc\boldsymbol{c}c,we defineΦ(x)\Phi (x)Φ(x)uesd Gauss functon :

Φ(x)=e−β∥x−c∥2\Phi(\boldsymbol{x})=e^{-\beta \|\boldsymbol{x}-\boldsymbol{c}\|^2}Φ(x)=e−β∥x−c∥2

which β\betaβcontrol the width of Gauss functon .

Note: It is not the only way. In fact, any similar δ\deltaδfunction is available.

Radial Basis Function Interpolation, RBF Interpolation , is essentially an interpolation method that use a linear combination of radial basis functions (RBFs) to
“exactly approximate” the functionf(x)f(x)f(x)at known points.The formular is as follows:

f(x)=∑j=1nλjΦj(x)=∑j=1nλje−βj∥x−cj∥2f(x)= \sum_{j=1}^{n} \lambda_j\Phi_j (\boldsymbol{x})= \sum_{j=1}^{n} \lambda_je^{-\beta_j \|\boldsymbol{x}-\boldsymbol{c}_j\|^2}f(x)=j=1∑n​λj​Φj​(x)=j=1∑n​λj​e−βj​∥x−cj​∥2

This defination is likeMaximum Likelihood Estimation。This likely unrigorous?No! Brommehead and Lowe had given the proof of
RBF
. Magically!

RBF Network

Radial Basis Function Network (RBF Network) is a type of feedforward neural network with a single hidden layer. Its core feature is that it adopts “radial basis functions (RBFs)” as the activation functions of the hidden layer, and it is specifically used to solve supervised learning tasks such as nonlinear regression, pattern classification, and function approximation. Its key advantages lie in “strong local approximation capability, fast training speed, and stable generalization performance”, making it widely applied in small and medium-sized nonlinear problems.

RBF Network

RBF Network=∑j=1nλjΦj(x)\text{RBF Network}=\sum_{j=1}^{n} \lambda_j\Phi_j (\boldsymbol{x})RBF Network=j=1∑n​λj​Φj​(x)

How to build a simple RBF network?

Aassuming we have series data{(x,y)}i=1n\{\left(\boldsymbol{x},y\right)\}_{i=1}^n{(x,y)}i=1n​, the training objective of an RBF network is to determine three types of parameters: hidden layer centers{ci}inc\{\boldsymbol{c}_i\}_{i}^{n_c}{ci​}inc​​, hidden layer widths{σi}inσ\{\sigma_i\}_{i}^{n_\sigma}{σi​}inσ​​, and output layer weights{wi}inw\{w_i\}_{i}^{n_w}{wi​}inw​​.

Step1: load data and K-means clustering

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.preprocessing import StandardScaler
import os
def preprocess_data(data):
data = data.dropna()
if data.dtypes.iloc[-1] == 'object' or len(data.iloc[:, -1].unique()) < 10:
X = data.iloc[:, :-1].values
has_labels = True
labels = data.iloc[:, -1].values
else:
X = data.values
has_labels = False
labels = None
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
return X_scaled, has_labels, labels
def perform_kmeans(X, n_clusters=neural_numbers, random_state=42):
kmeans = KMeans(n_clusters=n_clusters, random_state=random_state)
clusters = kmeans.fit_predict(X)
centroids = kmeans.cluster_centers_
return clusters, centroids
def visualize_results(X, original_labels, clusters, centroids, has_original_labels=False):
fig, axes = plt.subplots(1, 2, figsize=(16, 8))
has_original_labels and original_labels is not None:
scatter1 = axes[0].scatter(X[:, 0], X[:, 1], c=original_labels, cmap='viridis', alpha=0.7)
axes[0].set_title('oringal data distrbution', fontsize=14)
plt.colorbar(scatter1, ax=axes[0], label='oringal lable')
scatter2 = axes[1].scatter(X[:, 0], X[:, 1], c=clusters, cmap='viridis', alpha=0.7)
axes[1].scatter(centroids[:, 0], centroids[:, 1], s=300, c='red', marker='X', label='clustering center')
axes[1].set_title('result of clustering', fontsize=14)
plt.colorbar(scatter2, ax=axes[1], label='clustering label')
axes[1].legend()
for ax in axes:
ax.set_xlabel('feature_1(标准化)', fontsize=12)
ax.set_ylabel('feature_2(标准化)', fontsize=12)
ax.grid(True, linestyle='--', alpha=0.6)
plt.tight_layout()
if not os.path.exists('results'):
os.makedirs('results')
plt.savefig('results/clustering_comparison.png', dpi=300, bbox_inches='tight')
print("figures save to : results/clustering_comparison.png")
plt.show()
def main(file_path, n_clusters=3):
data = load_data(file_path)
if data is None:
return
X, has_labels, original_labels = preprocess_data(data)
if X.shape[1] > 2:
from sklearn.decomposition import PCA
print(f"data dimension is {X.shape[1]},use PCA to 2-dimension to showase")
pca = PCA(n_components=2)
X = pca.fit_transform(X)
clusters, centroids = perform_kmeans(X, n_clusters)
visualize_results(X, original_labels, clusters, centroids, has_labels)
if __name__ == "__main__":
datapath="data.csv"
neural_numbers=3
data = pd.read_csv(file_path) # Must .csv
main(datapath, neural_numbers)

**Step2: Calculate the hidden layer widths **$

The widths do not require training and are usually calculated automatically based on the distribution of the centers.Most commonly used,adaptive calculation based on “nearest neighbor center distance”

For each centercj\boldsymbol{c}_jcj​, first find another centerck\boldsymbol{c}_kck​that is closest to it (k≠jk \neq jk=j), and denote this distance asdjd_jdj​:

dj=min⁡k=1,2,...,nk≠j∥cj−ck∥d_j = \min_{\substack{k=1,2,...,n \\ k \neq j}} \|\boldsymbol{c}_j - \boldsymbol{c}_k\|dj​=k=1,2,...,nk=j​min​∥cj​−ck​∥

(wheredjd_jdj​represents the Euclidean distance from thejjj-th center to its nearest neighboring center)

Then, defineβj\beta_jβj​as a quantity related todjd_jdj​to ensure that the “effective range” of the RBF matches the distance between adjacent centers:

βj=12⋅dj2\beta_j = \frac{1}{2 \cdot d_j^2}βj​=2⋅dj2​1​

Step3: Solve for the output layer weights

After the centers{ci}\{\boldsymbol{c}_i\}{ci​}and widths{σi}\{\sigma_i\}{σi​}are determined, the hidden layer outputhi(x)h_i(\boldsymbol{x})hi​(x)can be regarded as a “fixed nonlinear feature”. At this point, the solution for the output layer weights is transformed into alinear regression problem(gradient descent is not required, and the least squares method can be used directly).

Suppose the training set containsNNNsamples(xk,yk)(\boldsymbol{x}_k, y_k)(xk​,yk​)(whereyky_kyk​is the true label), and the network output is$y^k=∑i=1mwihi(xk)+w0\hat{y}_k = \sum_{i=1}^m w_i h_i(\boldsymbol{x}_k) + w_0y^​k​=∑i=1m​wi​hi​(xk​)+w0​. By minimizing the “squared error between the predicted value and the true value”:

L=∑k=1N(y^k−yk)2\mathcal{L} = \sum_{k=1}^N (\hat{y}_k - y_k)^2L=k=1∑N​(y^​k​−yk​)2

This can be converted into the matrix equationH⋅w=y\mathbf{H} \cdot \boldsymbol{w} = \boldsymbol{y}H⋅w=y), where:

  • H\mathbf{H}H is an N×(m+1)N \times (m+1)N×(m+1)“feature matrix”, and each row is[1,h1(xk),h2(xk),...,hm(xk)][1, h_1(\boldsymbol{x}_k), h_2(\boldsymbol{x}_k), ..., h_m(\boldsymbol{x}_k)][1,h1​(xk​),h2​(xk​),...,hm​(xk​)](the 1 corresponds to the bias termw0w_0w0​);
  • w=[w0,w1,...,wm]T\boldsymbol{w} = [w_0, w_1, ..., w_m]^Tw=[w0​,w1​,...,wm​]Tis the weight vector to be solved;
  • y=[y1,y2,...,yN]T\boldsymbol{y} = [y_1, y_2, ..., y_N]^Ty=[y1​,y2​,...,yN​]Tis the true label vector.

The weights are solved using thepseudoinverse matrix(to avoid the problem of matrix singularity):

w=(HTH)−1HTy\boldsymbol{w} = (\mathbf{H}^T \mathbf{H})^{-1} \mathbf{H}^T \boldsymbol{y}w=(HTH)−1HTy

This step is the key to the fast training of the RBF network — linear problems can be solved directly without repeated iterations.

Later, we will construct a Radial Basis Function (RBF) network to accomplish the prediction task.

相关新闻

  • HTML常规 - ng
  • 2025年热门的特种纸印刷包装厂家推荐及选择参考
  • W3

最新新闻

  • Qwen3vl多模态后训练实战:LLamaFactory深度适配指南
  • 国产MLU算网+LLaMA-Factory:零代码微调百余大模型实战指南
  • 猫抓插件:3步搞定浏览器资源嗅探的终极指南
  • MPC866双核通信处理器架构解析与嵌入式网络设备开发实战
  • 存储型XSS漏洞实战解析:从DVWA靶场到安全防御
  • SRC漏洞挖掘实战:从信息搜集到逻辑漏洞的完整攻防指南

日新闻

  • 信任的进化:技术实现详解——如何用JavaScript构建博弈论模拟器
  • Terrakube自定义工作流:如何集成OPA、Infracost等工具扩展IaC能力
  • grunt-concurrent快速入门:5分钟学会并行运行Grunt任务

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号