Giter Site home page Giter Site logo

omaraflak / medium-python-neural-network Goto Github PK

View Code? Open in Web Editor NEW
103.0 9.0 42.0 19 KB

This code is part of my post on Medium.

Home Page: https://medium.com/@omaraflak/math-neural-network-from-scratch-in-python-d6da9f29ce65

Python 100.00%
neural-network from-scratch machine-learning backpropagation medium-article medium

medium-python-neural-network's Introduction

Mathematics of Neural Network

This code is part of my post on medium.

It shows how to create a neural network from scratch in Python, going all the way from the mathamatics to the code.

Run it

python example_xor.py
python example_conv.py
python example_mnist.py

medium-python-neural-network's People

Contributors

omaraflak avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

medium-python-neural-network's Issues

shapes are not aligned

Hi, I use your work in a learning goal. When I create small network with few layers everything works perfectly. But when i try this kind of network :
`reseau = Network()

reseau.add(FCLayer(8*8,100))
reseau.add(ActivationLayer(tanh, tanh_prime))
reseau.add(FCLayer(100,80))
reseau.add(ActivationLayer(tanh, tanh_prime))
reseau.add(FCLayer(80,60))
reseau.add(ActivationLayer(tanh, tanh_prime))
reseau.add(FCLayer(60,10))
reseau.add(ActivationLayer(tanh, tanh_prime))`

I have this issue when i use fit method :
`---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/tmp/ipykernel_367850/57939880.py in
1 reseau.use(mse, mse_prime)
----> 2 reseau.fit(learning_rate=0.0001, epochs=300, data_train=x_train, data_val=y_train)
3 reseau.show_fit()

~/Bureau/maths_python/14 avril/network.py in fit(self, learning_rate, epochs, data_train, data_val)
44
45 for layer in reversed(self.layers):
---> 46 error = layer.backward_propagation(error, learning_rate)
47
48 err /= iterations

~/Bureau/maths_python/14 avril/layer.py in backward_propagation(self, output_error, learning_rate)
49 def backward_propagation(self, output_error, learning_rate):
50 input_error = np.dot(output_error, self.weights.T)
---> 51 weights_error = np.dot(self.input.T, output_error)
52 # dBias = output_error
53

<array_function internals> in dot(*args, **kwargs)

ValueError: shapes (64,) and (1,100) not aligned: 64 (dim 0) != 1 (dim 0)`

When trying to debug it, I saw output_error changing type from ndarray to float64 but i really don't understand why.
Could you help me ? Thank in advance

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.