In [1]:
import numpy as np
import math as m
In [2]:
A = np.array([3,4,5]).reshape(3, 1)
B = np.zeros((3,1))
for i in range(len(A)):
    B[i] = m.exp(A[i])
    
B
Out[2]:
array([[ 20.08553692],
       [ 54.59815003],
       [148.4131591 ]])
In [3]:
B = np.exp(A)
B
Out[3]:
array([[ 20.08553692],
       [ 54.59815003],
       [148.4131591 ]])
In [4]:
def sigmoid(x):
    # we will use np.exp() so that we can calculate sigmoid function of a matrix or of a vector
    s = 1/(1 + np.exp(x))
    return s
In [5]:
sigmoid(0)
Out[5]:
0.5
In [6]:
# this line of code would not work if we had used math.exp() insted od np.exp()
sigmoid([1,0,5])
Out[6]:
array([0.26894142, 0.5       , 0.00669285])