-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbase.py
More file actions
36 lines (27 loc) · 705 Bytes
/
base.py
File metadata and controls
36 lines (27 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 7 18:19:23 2017
@author: fguignar1
"""
import numpy as np
def _Activation_function(M, func = 'logistic') :
'''
Parameters
----------
M : numpy array
Input matrix.
func : string, optional
Activation function (logistic or tanh). The default is 'logistic'.
Returns
-------
M : numpy array
Transformed input matrix.
'''
if func == 'logistic' :
M = 1/(1+ np.exp(-M))
elif func == 'tanh' :
M = np.tanh(M)
else :
raise TypeError("Only 'logistic' or 'tanh' are available for the activation function")
return M