surajdonthi / neural-networks-from-scratch Goto Github PK
View Code? Open in Web Editor NEWArticles related to Neural Networks will be posted here.
License: Apache License 2.0
Articles related to Neural Networks will be posted here.
License: Apache License 2.0
TypeError Traceback (most recent call last)
<ipython-input-23-9dc180f7b768> in <module>
20 losses.append(loss)
21
---> 22 m, b = grad_desc(X_train, y_train, y_pred, m, b, l_r)
23
24 if(i%10==0):
<ipython-input-21-221a3b5972ba> in grad_desc(X_train, y_train, y_pred, m, b, l_r)
1 def grad_desc(X_train, y_train, y_pred, m, b, l_r):
2
----> 3 dm, db = gradient(m, b, X_train, y_train, y_pred)
4
5 m, b = update_params(m, b, dm, db, l_r)
TypeError: cannot unpack non-iterable NoneType object
โ
This last part
losses = []
for i in range(epochs):
y_pred = forward_prop(X_train, m,b)
loss = compute_loss(y_train, y_pred)
losses.append(loss)
m,b = grad_desc(X_train, y_train, y_pred, m, b, l_r)
if(i%10==0):
print('Epoch: ', i)
print('Loss = ', loss)
prints a table of decreasing losses but no graphs.
Ifixed it by adding a return statement to the pred_line function like so
def plot_pred_line(X, y, m, b,losses=None):
# Generate a set of datapoints on x for creating a line.
# We shall consider the range of X_train for generating the line so that the line superposes the datapoints.
x_line = np.linspace(np.min(X), np.max(X), 10)
# Calculate the corresponding y with the parameter values of m & b
y_line = m * x_line + b
dataset = {'X': X, 'y': y}
pred_line = {'x_line': x_line, 'y_line':y_line}
plot_graph(dataset, pred_line)
return pred_line
and adding the following two lines to the last part
pred_line=plot_pred_line(X_train, y_train, m, b,losses)
plot_graph(dataset, pred_line, losses)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.