import torchdef CORAL(source, target):d = source.data.shape[1] #coral公式中的分母部分ns, nt = source.data.shape[0], target.data.shape[0]# source covariancexm = an(source, 0, keepdim=True) - source #对应着Cs的分子部分xc = xm.t() @ xm/(ns-1) #对应着Cs的分子部分# target covariancexmt = an(target, 0, keepdim=True) - target#对应着Ct的分子部分xct = xmt.t() @ xmt/(nt-1)#对应着Ct的分子部分# frobenius norm between source and targetloss = an(torch.mul((xc - xct), (xc - xct))) #Cs-Ct的点乘loss = loss/(4*d*d)return loss
Coral公式:
只做学习使用,作者也是看了别人进行了学习总结,希望能对你有所帮助。
故障诊断与python学习
Deep CORAL: Correlation Alignment for Deep Domain Adaptation_gdtop818的博客-CSDN博客
本文发布于:2024-02-04 21:13:32,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170716538859657.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |