Question: Receiving an error: Traceback (most recent call last): nw = weights + dhs.reshape(2, 3) / (x + 0.0000001) ValueError: cannot reshape array of size 3

Receiving an error:

Traceback (most recent call last):

nw = weights + dhs.reshape(2, 3) / (x + 0.0000001) ValueError: cannot reshape array of size 3 into shape (2,3)

import numpy as np

x1,x2 = input("Enter two values: ").split()

w1,w2,w3,w4,w5,w6 = input("Enter six values: ").split()

k1,k2,k3 = input("Enter three values: ").split()

x = np.array([int(x1), int(x2)], dtype=float) weights = np.array([float(w1), float(w2), float(w3), float(w4), float(w5), float(w6)], dtype=float).reshape(2, 3) k = np.array([float(k1), float(k2), float(k3)], dtype=float) m = np.dot(x, weights) p = 1 / (1 + np.exp(-m)) sm = np.dot(p, k) y = 1 / (1 + np.exp(-sm))

print("y = ", y)

res = 0 - y q1 = res * (np.exp(-sm)) / ((1 + np.exp(-sm))**2) dw = q1 * p / (p + 0.0000001) nk = k + dw dhs = q1 * (1 + np.exp(-np.abs(m)))**2 / k * np.exp(-np.abs(m)) nw = weights + dhs.reshape(2, 3) / (x + 0.0000001)

k = nk weights = nw

m = np.dot(x, weights) p = 1 / (1 + np.exp(-m)) sm = np.dot(p, k) y = 1 / (1 + np.exp(-sm))

print("y = ", y)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!