1 Star 0 Fork 0

binqiang2wang/DUAL

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
loss_dual.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Mahd 提交于 2021-12-21 14:46 . init
import torch
import torch.nn as nn
from utils import *
class AEloss(nn.Module):
def __init__(self):
super(AEloss, self).__init__()
def forward(self, x, encoder, decoder, C1, C2, latent_c, \
latent_cluster, cluster_center):
# The Reconstructed Loss
recon_loss = torch.sum(torch.pow((decoder - x), 2.0))
# The L2,1 Norm of C1
C1_loss = sparse_colmun(C1)
diag_C1_loss = torch.sum(torch.diag(C1 ** 2.0))
# The L2,1 Norm of C2
C2_loss = sparse_colmun(C2)
# Self-expression of C1
self_C1_loss = torch.sum(torch.pow((latent_c - encoder), 2.0))
# Self-expression of C2
self_C2_loss = torch.sum(torch.pow((latent_cluster - cluster_center), 2.0))
loss = {
'recon_loss': recon_loss,
'C1_loss': C1_loss,
'C2_loss': C2_loss,
'self_C1_loss': self_C1_loss,
'diag_C1_loss': diag_C1_loss,
'self_C2_loss': self_C2_loss
}
return loss
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bq2w/DUAL.git
[email protected]:bq2w/DUAL.git
bq2w
DUAL
DUAL
master

搜索帮助