当前位置:网站首页>NMF-matlab
NMF-matlab
2022-07-02 18:38:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
matlab练习程序(非负矩阵分解)
这个算法是Lee和Seung在1999年发表在nature杂志上的。具体论文看这里:http://www.seas.upenn.edu/~ddlee/Papers/nmf.pdf。
看不懂英文没关系,可以看这个中文的介绍:http://wenku.baidu.com/view/94c8af0bf78a6529647d5331.html。
原理上面两篇文章已经很清楚了,我在按自己的理解介绍一下吧。
通常矩阵分解如svd或其他什么的分解都会把矩阵分解为有正有负的矩阵,而他的这种分解方法就把矩阵完全分解成只有正数的矩阵,因为现实世界中如图像,负数是没什么意义的,所以这种只分解为正数矩阵的分解方法就很有意义了,要不也不会发在nature这样牛B的杂志上。
这里是分解的公式:
这里r是分解矩阵的秩,V是原矩阵的一个近似,W与H就是分解而成的两个矩阵。
下面是W和H的求法,是一个迭代算法,初始的W与H是随机的就行了:
关于代码,我借鉴了这个博客的:http://fxy1211.blog.163.com/blog/static/68255322007826111015905/,真是太感谢这位博主了。
下面是代码:
clear all; close all; clc; V=double(imread('lena.jpg')); imshow(mat2gray(V)); [i u]=size(V); %计算V的规格 r=100; %设置分解矩阵的秩 W=rand(i,r); %初始化WH,为非负数 H=rand(r,u); maviter=100; %最大迭代次数 for iter=1:maviter W=W.*((V./(W*H))*H'); %注意这里的三个公式和文中的是对应的
W=W./(ones(i,1)*sum(W)); H=H.*(W'*(V./(W*H)));
end img_V=W*H; figure; imshow(mat2gray(img_V));下面是原图和重构后的效果,如果秩和迭代次数越大,那么重构后的图越接近原图:
原图
重构图
因为这个是看自己相关方向论文偶然在一篇论文的引用中看到了这个算法,所以就稍微了解了一下,肯定有不妥的地方,就这样吧。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/148571.html原文链接:https://javaforall.cn
边栏推荐
- AcWing 342. 道路与航线 题解 (最短路、拓扑排序)
- Quanzhi A33 uses mainline u-boot
- 搭建哨兵模式reids、redis从节点脱离哨兵集群
- pxe装机「建议收藏」
- 嵌入式(PLD) 系列,EPF10K50RC240-3N 可编程逻辑器件
- Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
- Tutorial (5.0) 10 Troubleshooting * fortiedr * Fortinet network security expert NSE 5
- 《代码整洁之道》读书笔记
- Thread application instance
- 【pytorch学习笔记】Tensor
猜你喜欢

《重构:改善既有代码的设计》读书笔记(下)

Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5

数据降维——主成分分析

SQLite 3.39.0 发布,支持右外连接和全外连接

全志A33使用主线U-Boot

Refactoring: improving the design of existing code (Part 1)

数据降维——因子分析

AcWing 342. Road and route problem solving (shortest path, topological sorting)

Codeworks 5 questions per day (1700 average) - day 4

Data dimensionality reduction principal component analysis
随机推荐
AcWing 1137. Select the best line solution (the shortest circuit)
IEDA refactor的用法
Codeforces Round #802 (Div. 2) 纯补题
LeetCode 0871.最低加油次数 - 类似于POJ2431丛林探险
函数高阶-柯里化实现
AcWing 1134. 最短路计数 题解(最短路)
AcWing 342. Road and route problem solving (shortest path, topological sorting)
Golang concurrent programming goroutine, channel, sync
搭建哨兵模式reids、redis从节点脱离哨兵集群
Bubble sort array
Use cheat engine to modify money, life and stars in Kingdom rush
AcWing 341. 最优贸易 题解 (最短路、dp)
451-memcpy、memmove、memset的实现
Gamefi chain game system development (NFT chain game development function) NFT chain game system development (gamefi chain game development source code)
数据降维——因子分析
Which video recording software is better for the computer
AcWing 1137. 选择最佳线路 题解(最短路)
Microservice technology - distributed global ID in high concurrency
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
Mobile robot path planning: artificial potential field method [easy to understand]