Last active
November 26, 2019 03:11
-
-
Save chrico-bu-uab/63ba87c18f8a314e1062f6d86254f285 to your computer and use it in GitHub Desktop.
which version is better?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.special import expit | |
class Eswish1(Layer): | |
def __init__(self, beta): | |
self.ReLUness = 0 | |
self.layertype = 'Eswish' | |
self.beta = beta | |
def forward(self, input, is_train): | |
self.input = input | |
self.sigmoid = expit(input) | |
self.fx = self.beta * input * self.sigmoid | |
return self.fx | |
def backward(self, dy): | |
grad = self.fx + self.sigmoid * (self.beta - self.fx) | |
return dy*grad | |
class Eswish2(Layer): | |
def __init__(self, beta): | |
self.ReLUness = 0 | |
self.layertype = 'Eswish' | |
self.beta = beta | |
def forward(self, input, is_train): | |
self.input = input | |
sigmoid = expit(input) | |
fx = self.beta * input * sigmoid | |
self.grad = fx + sigmoid * (self.beta - fx) | |
return fx | |
def backward(self, dy): | |
return dy*self.grad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment