Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
JiauZhang committed Apr 18, 2023
1 parent ae88758 commit 08b783b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

```shell
pip install lossers
# or install from source
pip install git+https://github.com/JiauZhang/lossers.git
```
18 changes: 18 additions & 0 deletions examples/lpips_loss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import torch
from lossers.lpips import LPIPS


loss_fn = LPIPS(net='vgg')
source = torch.randn((1, 3, 32, 32), requires_grad=False)
target = torch.randn((1, 3, 32, 32), requires_grad=True)
optimizer = torch.optim.Adam([target], lr=1e-3, betas=(0.9, 0.999))

for i in range(1000):
loss = loss_fn(source, target)
loss = 0
optimizer.zero_grad()
loss.backward()
optimizer.step()

if i % 10 == 0:
print('loss info:', loss.item())
2 changes: 1 addition & 1 deletion lossers/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def mse_loss(input, target, **kwargs):
return F_.mse_loss(input, target, **kwargs)

def l2_loss(input, target, **kwargs):
return F_.l2_loss(input, target, **kwargs)
return F_.mse_loss(input, target, **kwargs)
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

setup(
name = 'lossers',
packages = find_packages(),
version = '0.0.3',
packages = find_packages(exclude=['examples']),
package_data={'': ['*/vgg_v0.1.pth']},
version = '0.0.4',
license='MIT',
description = 'ML Loss Function',
description = 'ML/DL Loss Function',
author = 'JiauZhang',
author_email = 'jiauzhang@163.com',
url = 'https://github.com/JiauZhang/lossers',
long_description=open("README.md", "r", encoding="utf-8").read(),
long_description_content_type = 'text/markdown',
keywords = [
'artificial intelligence',
Expand All @@ -21,6 +23,6 @@
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.8',
],
)

0 comments on commit 08b783b

Please sign in to comment.