Git Product home page Git Product logo

cyclemoid-pytorch's Introduction

This is an implementation of the cyclemoid activation function for PyTorch.

The cyclemoid function achieved state-of-the-art results in a recent benchmark with other popular activation functions as shown below:

Note that this is a figure from the paper submitted on April 1st, 2022. An arxiv preprint will be uploaded soon.

Installation

You can install the cyclemoid-pytorch package via

pip install cyclemoid_pytorch

Usage

This package implements a CycleMoid class and a cyclemoid function. You can use these are drop-in replacements for any activation in PyTorch. For example

from cyclemoid_pytorch import CycleMoid

torch.nn.Sequential(
    # ...,
    CycleMoid(), # instead of torch.nn.ReLU()
    # ...
    )

or

from cyclemoid_pytorch import cyclemoid

# ...
def forward(self, x):
    # ...
    x = cyclemoid(x) # instead of torch.sigmoid(x)

Visualization

import matplotlib.pyplot as plt
import torch
from cyclemoid_pytorch import cyclemoid

x = torch.arange(-5, 5, 0.01)
y = cyclemoid(x)
plt.plot(x, y)

Demo

For a concrete usage, check out the demo notebook.

Appendix

You can now also use the cyclemoid activation in Keras.

import tensorflow as tf
from cyclemoid_pytorch.easteregg import CycleMoid


tf.keras.utils.get_custom_objects()['cyclemoid'] = CycleMoid

model = tf.keras.Sequential(
    [
        tf.keras.Input(...),
        tf.keras.layers.Conv2D(..., activation="cyclemoid"),
        # ... 
    ]
)

cyclemoid-pytorch's People

Contributors

rasbt 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.