Git Product home page Git Product logo

differentiation's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

differentiation's Issues

Biases are being broadcasted

When two matrices of shape (4, 4) and (4,) are being added, the (4,)-shaped matrix will be broadcasted to the shape (4, 4) by repeating their rows:

>>> A = np.zeros((4, 4))
>>> biases = np.array([1, 2, 3, 4])
>>> C = A + biases
>>> C
array([[ 1.,  2.,  3.,  4.],
       [ 1.,  2.,  3.,  4.],
       [ 1.,  2.,  3.,  4.],
       [ 1.,  2.,  3.,  4.]])

This causes trouble during backpropagation because both A and biases will receive a matrix of shape (4, 4) although the biases are only of shape (4,).
If the biases are then updated like biases = biases - grad, the biases will be broadcasted to shape (4, 4).

I tried to implement neural networks in a similar way and made the same mistake, but numpy caught it because I wrote biases -= grad instead which will throw an error instead of broadcasting.

I think the solution might be to squish the matrices back to their source shape when backpropagating:

>>> np.sum(C, 0)
array([  4.,   8.,  12.,  16.])

but it does not seem very elegant to me to do it this way and I also tried this network for the mnist data set and got a warning that exp overflowed, so I might be wrong everywhere.
EDIT: Some other guy is doing a np.mean instead.

If the following code is inserted at
https://github.com/jimfleming/differentiation/blob/master/main.py#L106
it can be seen that the biases change their shape from (4,) to (4,4) and from (1,) to (4,1).
This makes it too easy to train the network because there now is a free variable for every point of data at the end of the neural network.

    print(sess.state[biases0])
    print(sess.state[biases1])

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.