Code Monkey home page Code Monkey logo

alpha-relu's Introduction

Alpha-ReLU

This package provides a pytorch implementation of α-ReLU and α-ReLU loss for α=1.5

Requirements: python 3, pytorch >= 1.0

The library based on the implementation of entmax

Example

In [1]: import torch

In [2]: from torch.nn.functional import softmax

In [2]: from alpharelu import relu15

In [4]: x = torch.tensor([-2, 0.3, 0.5])

In [5]: softmax(x, dim=0)
Out[5]: tensor([0.0432, 0.4307, 0.5261])

In [6]: relu15(x, dim=0)
Out[6]: tensor([0.0000, 0.0225, 0.0625])

Loss

In [1]: import torch

In [2]: from alpharelu import ReLU15Loss

Note, that relu15 and ReLU15Loss takes optional tau argument (default: 0.0) which is responsible to the value of in image Optimal value of can be obtained by:

from alpharelu import get_tau
optimal_tau = get_tau(x/2)
relu15(x, dim=-1, tau=optimal_tau)

where x is the logits of the first batch. Note, that for 1.5-ReLU, you need to pass x/2 to get_tau function.

Installation

pip install alpharelu

Citations

Speeding Up Entmax

@article{DBLP:journals/corr/abs-2111-06832,
  author    = {Maxat Tezekbayev and
               Vassilina Nikoulina and
               Matthias Gall{\'{e}} and
               Zhenisbek Assylbekov},
  title     = {Speeding Up Entmax},
  journal   = {CoRR},
  volume    = {abs/2111.06832},
  year      = {2021},
  url       = {https://arxiv.org/abs/2111.06832},
  eprinttype = {arXiv},
  eprint    = {2111.06832},
  timestamp = {Tue, 16 Nov 2021 12:12:31 +0100},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2111-06832.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

alpha-relu's People

Contributors

maxattezekbayev avatar

Stargazers

Muhammad Rizqi Nur avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.