Code Monkey home page Code Monkey logo

trainableactivation's Introduction

PWC PWC

Trainable Activations for Image Classification

We propose a set of the trainable activation functions — Cosinu-Sigmoidal Linear Unit (CosLU), DELU, Linear Combination (LinComb), Normalized Linear Combination (NormLinComb), Rectified Linear Unit N (ReLUN), Scaled Soft Sign (ScaledSoftSign), Shifted Rectified Linear Unit (ShiLU).

Pretrained weights.

CosLU

$$CosLU(x) = (x + \alpha \cos(\beta x))\sigma(x)$$

$$\sigma(x) = \frac{1}{1 + e^{-x}}$$

CosLU

DELU

$$ DELU(x) = \begin{cases} SiLU(x), x \leqslant 0 \\ (n + 0.5)x + |e^{-x} - 1|, x > 0 \end{cases} $$

$$SiLU(x) = x\sigma(x)$$

DELU

LinComb

$$LinComb(x) = \sum\limits_{i=0}^{n} w_i \mathcal{F}_i(x)$$

LinComb

NormLinComb

$$NormLinComb(x) = \frac{\sum\limits_{i=0}^{n} w_i \mathcal{F}_i(x)}{\mid \mid W \mid \mid}$$

NormLinComb

ReLUN

$$ReLUN(x) = min(max(0, x), n)$$

ReLUN

ScaledSoftSign

$$ScaledSoftSign(x) = \frac{\alpha x}{\beta + |x|}$$

ScaledSoftSign

ShiLU

$$ShiLU(x) = \alpha ReLU(x) + \beta$$

$$ReLU(x) = max(0, x)$$

ShiLU

INSTALLATION

Create venv.

python3 -m venv venv

Activate venv.

source venv/bin/activate

Install dependencies.

pip install -r requirements.txt

PROJECT STRUCTURE

There are 3 main files - train.py, test.py, plot.py. You should run train.py first, then test.py, then plot.py.

Use whatever configuration you want to test. Configurations can be found in the configs folder, train.py and test.py use the same config. There are several plot configurations in the configs/plot folder.

There are many predefined run scripts in the scripts folder, just run one of them as .sh, scripts/train.sh and scripts/test.sh are scripts to train and test all possible configurations, scripts/plot.sh to plot results after training and testing.

All the results of the train / test phases are in the logs folder.

All proposed trainable activations are in activation.py.

HOW TO RUN

Let's say I want to train and test the ResNet-8 model with CosLU trainable activation on the CIFAR-10 dataset.

python train.py --config configs/coslu/cifar10/resnet8.yaml
python test.py --config configs/coslu/cifar10/resnet8.yaml

If you want to train and test all proposed trainable activations with a specific model and dataset, you can use the script from the scripts folder. For example, train and test the DNN2 model on the MNIST dataset.

sh scripts/dnn2_mnist.sh

Train and test all possible configurations.

sh scripts/train.sh
sh scripts/test.sh

Plot graphics for all configurations, it will work even if some configurations haven't been trained.

sh scripts/plot.sh

CITATION

Project CITATION.

LICENSE

Project is distributed under MIT License.

trainableactivation's People

Contributors

pe4eniks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

mohammed1916

trainableactivation's Issues

How to solve this problem?

I'm having trouble running your code train.py. How to solve this problem?Thank you!
Traceback (most recent call last):
File "C:\Users\27479\Desktop\TrainableActivation-main\train.py", line 171, in
train()
File "C:\Users\27479\Desktop\TrainableActivation-main\train.py", line 26, in train
args = parse()
File "C:\Users\27479\Desktop\TrainableActivation-main.\tools.py", line 12, in parse
with open(args.config) as stream:
FileNotFoundError: [Errno 2] No such file or directory: './configs.yaml'

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.