When I give following command it works:
W2 = np.array( [[ 0.00874286,-0.01293537,-0.00079741,0.00564486,0.01233471]])
b2=np.array([[0.]])
a=np.array([[11.2,11.0,12.7],[10.1,34.4,4.0],[9.0,7.9,6.6],[8.5,8.0,9.45,],[5.5,9.9,8.3]])
Z = np.dot(W2,a)+b2
print(1/(1+np.exp(-Z)))
Output is:
[[0.51897047 0.4531795 0.55224658]]
but when I give it following it generates error:
Z = np.dot(parameters['W2'],A)+parameters['b2']
print(1/(1+np.exp(-Z)))
where A, parameters['W2], parameters['b2'] are numpy array and have float values. Output is:
AttributeError Traceback (most recent call last)
AttributeError: 'float' object has no attribute 'exp'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
<ipython-input-26-dc868b05af37> in <module>()
3 Z = np.dot(parameters['W2'],A)+parameters['b2']
4 #A1,C=linear_sigmoid_forward(A, parameters['W2'],parameters['b2'])
----> 5 print(1/(1+np.exp(-Z)))
TypeError: loop of ufunc does not support argument 0 of type float which has no callable exp method
In Both cases I've given float numpy arrays, but it generates error in second case. Why???