https://github.com/samet-akcay/ganomaly
Revision 5bae999fc61b8a6156654cce34625d399fae0515 authored by samet-akcay on 30 October 2019, 11:19:40 UTC, committed by GitHub on 30 October 2019, 11:19:40 UTC
Bump pillow from 6.1.0 to 6.2.0
Tip revision: 5bae999fc61b8a6156654cce34625d399fae0515 authored by samet-akcay on 30 October 2019, 11:19:40 UTC
Merge pull request #55 from samet-akcay/dependabot/pip/pillow-6.2.0
Merge pull request #55 from samet-akcay/dependabot/pip/pillow-6.2.0
Tip revision: 5bae999
loss.py
"""
Losses
"""
# pylint: disable=C0301,C0103,R0902,R0915,W0221,W0622
##
# LIBRARIES
import torch
##
def l1_loss(input, target):
""" L1 Loss without reduce flag.
Args:
input (FloatTensor): Input tensor
target (FloatTensor): Output tensor
Returns:
[FloatTensor]: L1 distance between input and output
"""
return torch.mean(torch.abs(input - target))
##
def l2_loss(input, target, size_average=True):
""" L2 Loss without reduce flag.
Args:
input (FloatTensor): Input tensor
target (FloatTensor): Output tensor
Returns:
[FloatTensor]: L2 distance between input and output
"""
if size_average:
return torch.mean(torch.pow((input-target), 2))
else:
return torch.pow((input-target), 2)
Computing file changes ...