Skip to content

Commit

Permalink
循环神经网络
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Cherish committed Dec 18, 2018
1 parent 5850b3b commit f693e15
Show file tree
Hide file tree
Showing 3 changed files with 631 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Tutorial/lesson-5/activators.py
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
Loading

0 comments on commit f693e15

Please sign in to comment.