function [patterns, targets, W, Aw, means] = ICA(patterns, targets, params)
%Reshape the data points using the independent component analysis algorithm
%Inputs:
% train_patterns - Input patterns
% train_targets - Input targets
% params - [Output dimension, Learning rate]
%
%Outputs
% patterns - New patterns
% targets - New targets
% W - Reshape martix
% means - The means vector of the patterns
[r,c] = size(patterns);
[dimension, eta] = process_params(params);
if (r < dimension),
error('Output dimension cannot be larger than the input dimension')
end
%Whiten the data to zero mean and unit covariance
means = mean(patterns')';
patterns = patterns - means*ones(1,c);
[v, d] = eig(cov(patterns',1));
Aw = v*inv(sqrtm(d));
patterns = Aw'*patterns;
%Move data to the range of [-1,1]
minp = min(patterns')';
maxp = max(patterns')';
patterns = (patterns - minp*ones(1,c))./((maxp-minp)*ones(1,c));
patterns = patterns*2-1;
%Find the weight matrix
W = randn(r);
iter = 1;
while (iter < 1000),
iter = iter + 1;
y = W*patterns;
phi = activation(y);
dW = (eye(r) - 1/c*phi*y')*W;
%Break if algorithm diverges
if (max(max(dW)) > 1e3),
disp(['Algorithm diverged after ' num2str(i) ' iterations'])
break
end
W = W + eta*dW;
update = max(max(abs(dW)));
%If the algorithm converged, exit
if (update < eta),
disp(['Algorithm converged after ' num2str(iter) ' iterations'])
break
else
if (iter / 10 == floor(iter/10))
disp(['Iteration ' num2str(iter) ': Maximum update is ' num2str(update)])
end
end
end
%Take only the most influential outputs
power = sum(abs(W)');
[m, in] = sort(power);
W = W(in(r-dimension+1:r),:);
%Calculate new patterns
patterns = W*patterns;
W = W*Aw;
%End ICA
function phi = activation(y)
%Activation function for ICA
phi = y.^3;
%phi = tahn(y);
ICA.rar_ica 特征_模式识别
版权申诉
190 浏览量
2022-09-24
20:26:58
上传
评论
收藏 1001B RAR 举报
alvarocfc
- 粉丝: 111
- 资源: 1万+
最新资源
- stm32cubemx can通信 一个板子负责传感器采集 一个板子负责wifi传递到网页 网页可控制传感器板子.zip
- k8s集群搭建1.27.1版本(来源于图灵k8s笔记)
- 树莓派连接 DS18B20 温度传感器读取温度时监控客户端,服务器端连接状况,实现断线重连机制
- 最好用的富文本编辑器wangeditor
- jQuery 3.7.1
- 校园失物招领小程序源码可作毕业设计
- SAP客户端GUI740安装包(JAVA版本)
- winlibs-x86-64-posix-seh-gcc-13.2.0-llvm-16.0.6-mingw-w64msvcrt
- HTML5小游戏【愤怒的小红帽-优秀H5小游戏合集射击游戏-过关游戏】游戏源码分享下载 - fndxhm.zip
- 医学影像处理-图像分割-肿瘤识别-诊断辅助-matlab图像分割肿瘤代码-DeepBTSeg.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0