Giter Site home page Giter Site logo

neural-networks-from-scratch's People

Contributors

surajdonthi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

neural-networks-from-scratch's Issues

error in make_regression


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

โ€‹

plots missing?

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.