Skip to content

Commit

Permalink
fix loss (close #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
SSARCandy authored May 21, 2018
1 parent 270e679 commit 200f7c8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def CORAL(source, target):
d = source.data.shape[1]

# source covariance
xm = torch.mean(source, 1, keepdim=True) - source
xc = torch.matmul(torch.transpose(xm, 0, 1), xm)
xm = torch.mean(source, 0, keepdim=True) - source
xc = xm.t() @ xm

# target covariance
xmt = torch.mean(target, 1, keepdim=True) - target
xct = torch.matmul(torch.transpose(xmt, 0, 1), xmt)
xmt = torch.mean(target, 0, keepdim=True) - target
xct = xmt.t() @ xmt

# frobenius norm between source and target
loss = torch.mean(torch.mul((xc - xct), (xc - xct)))
Expand Down

0 comments on commit 200f7c8

Please sign in to comment.