import numpy as np
# Given parameters
m1 = 2
c1 = 3
x1 = 4
m2 = 1.5
c2 = 1
delta = 0.5
# Create a matrix 'm' (2x2) with custom coefficients
m = np.array([[m1, c1], [m2, c2]])
print("m = ",m)
# Calculate y1
y1 = np.dot(m, np.array([x1, 1])) # [m11*x1 + m12, m21*x1 + m22]
print("y1 = ", y1)
# Calculate y2 using the sigmoid function
def sigmoid(x):
return 1 / (1 + np.exp(-x))
y2 = sigmoid(y1)
print("y2 = ", y2)
# Calculate y3
y3 = np.dot(m, np.array([y2, 1]).T) # [m11*y2 + m12, m21*y2 + m22]
# Calculate y4 using the sigmoid function
y4 = sigmoid(y3)
# Check if y4 > delta
result = y4 > delta
print("Matrix m:\n", m)
print("y1:", y1)
print("y2:", y2)
print("y3:", y3)
print("y4:", y4)
print("y4 > delta:", result)
I am getting this error -
m = [[2. 3. ]
[1.5 1. ]]
y1 = [11. 7.]
y2 = [0.9999833 0.99908895]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-7919dd51c859> in <cell line: 25>()
23
24 # Calculate y3
---> 25 y3 = np.dot(m, np.array([y2, 1]).T) # [m11*y2 + m12, m21*y2 + m22]
26
27 # Calculate y4 using the sigmoid function
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.