/
githubmirror
/
ailearning
Обзор
Документация
Войти
/
githubmirror
/
ailearning
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/py3.x/dl/activators.py
38 строк
878 B
jiangzhonglian
git 项目大瘦身
11 окт 2019, 11:48
11 окт 2019, 11:48
81abcb3
Код
Авторство
О чём код?
#!/usr/bin/env python # -*- 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 np.longfloat(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