Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago

Question

8. How would you explain your decisions to the city council?

Answered: 1 week ago