forked from Jack-Cherish/Deep-Learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5850b3b
commit f693e15
Showing
3 changed files
with
631 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: UTF-8 -*- | ||
|
||
|
||
import numpy as np | ||
|
||
|
||
class ReluActivator(object): | ||
def forward(self, weighted_input): | ||
#return weighted_input | ||
return max(0, weighted_input) | ||
|
||
def backward(self, output): | ||
return 1 if output > 0 else 0 | ||
|
||
|
||
class IdentityActivator(object): | ||
def forward(self, weighted_input): | ||
return weighted_input | ||
|
||
def backward(self, output): | ||
return 1 | ||
|
||
|
||
class SigmoidActivator(object): | ||
def forward(self, weighted_input): | ||
return 1.0 / (1.0 + np.exp(-weighted_input)) | ||
|
||
def backward(self, output): | ||
return output * (1 - output) | ||
|
||
|
||
class TanhActivator(object): | ||
def forward(self, weighted_input): | ||
return 2.0 / (1.0 + np.exp(-2 * weighted_input)) - 1.0 | ||
|
||
def backward(self, output): | ||
return 1 - output * output |
Oops, something went wrong.