问题描述
我在使用 R 的 NMF 函数实现我想要的确切模型时遇到问题。 我想要的是通过添加另一个术语来改变 NMF 模型的“正常”目标函数,这说明了我拥有的一些数据。
也就是说,我希望使用最小化欧几里得距离并使用乘法更新(“lee”算法)的“标准”NMF模型,然后将另一个形式的项添加到该距离上:
α ⋅ ‖W(1) − γ M‖
其中 M 是“我的数据”,W(1) 是第一个隐藏因子,α 和 γ 是要调整的参数。
文档不是很有帮助。以下示例来自 R 的 NMF documentation:
n <- 50; r <- 3; p <- 20
V <-syntheticNMF(n,r,p)
my.algorithm <- function(x,seed,scale.factor=1){
# do something with starting point
# ...
# for example:
# 1. compute principal components
pca <- prcomp(t(x),retx=TRUE)
# 2. use the absolute values of the first PCs for the Metagenes
# Note: the factorization rank is stored in object 'start'
factorization.rank <- nbasis(seed)
Metagenes(fit(seed)) <- abs(pca$rotation[,1:factorization.rank])
# use the rotated matrix to get the mixture coefficient
# use a scaling factor (just to illustrate the use of extra parameters)
Metaprofiles(fit(seed)) <- t(abs(pca$x[,1:factorization.rank])) / scale.factor
# return updated data
return(seed)
}
my.objective <- function(model,target,p_alpha,p_gamma){
(sum((target-fitted(model))^4 ) )^{1/4}
}
res = nmf(V,3,my.algorithm,seed='nndsvd',objective=my.objective)
但是,如果我理解正确的话,为了改变目标函数,我需要从头开始编写自己的算法,我不知道该怎么做。
关于如何实现我想要的任何帮助,将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)