代码拉取完成,页面将自动刷新
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。