GithubHelp home page GithubHelp logo

johnny7861532 / activation-function-swish-in-keras Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 351 KB

Google just release a paper to describe a new activation function: SWISH: A SELF-GATED ACTIVATION FUNCTION

activation-function-swish-in-keras's Introduction

Activation-function-swish-in-Keras

Google just release a paper to describe a new activation function: SWISH: A SELF-GATED ACTIVATION FUNCTION

According to the paper is new self-gate activation function is more powerful than relu, and can improves neural net's accuarcy by just simple replace relu with swish.

Paper is here to offer: https://arxiv.org/pdf/1710.05941.pdf

here is how to put it into Keras.

from keras.models import Sequential
from keras.layers import Dense,Activation
from keras import optimizers
from sklearn.utils import class_weight
from keras import backend as K

def swish(x):
    return K.sigmoid(x) * x

adam = optimizers.Adam(lr = 0.005)
classifier = Sequential()
classifier.add(Dense(units = 10,activation = swish,kernel_initializer = 'uniform',input_dim = 10))
classifier.add(Dense(units = 50,activation = swish, kernel_initializer = 'uniform'))
classifier.add(Dense(units = 25,activation = swish, kernel_initializer = 'uniform'))
classifier.add(Dense(units = 10,activation = swish, kernel_initializer = 'uniform'))
classifier.add(Dense(units = 5,activation = swish, kernel_initializer = 'uniform'))
classifier.add(Dense(units = 1,activation = 'sigmoid',kernel_initializer = 'uniform'))
classifier.compile(optimizer = adam,loss = 'binary_crossentropy'
                   ,metrics = ['accuracy'])

classifier.fit(x_train,y_train,batch_size = 100,epochs = 100,validation_data  =(x_test,y_test)
,shuffle = True)

If swish really better than relu?

swish confusion matrix

image

relu confusion matrix

image

swish training history

image

relu training history

image

it seems that swish is not powerful as I expect, and swish need about 20% extra time to train.

Also compare with their training history, relu seem got better training curve.

So far I can't feel the power of the swish activation function.

activation-function-swish-in-keras's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

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