eriklindernoren / ML-From-Scratch

Machine Learning From Scratch. Bare bones NumPy implementations of machine learning models and algorithms with a focus on accessibility. Aims to cover everything from linear regression to deep learning.
MIT License
23.56k stars 4.55k forks source link

Runtime error during backward_pass() of PoolingLayer #72

Open krworks opened 4 years ago

krworks commented 4 years ago

I greatly appreciate your work and clearly written code which gives incredible insights into the back propagation technique. I've encountered a bit of a bug which is pretty solvable, but I don't want to make a pull request as I'm not sure of default values here.

It's at layers.py:400 (at the end of the line, last param): https://github.com/eriklindernoren/ML-From-Scratch/blob/a2806c6732eee8d27762edd6d864e0c179d8e9e8/mlfromscratch/deep_learning/layers.py#L400 The last param is supposed to be in the string-style enum format of padding type. It's passing a literal 0 when it should be passing self.padding. PoolingLayer should also have a valid default value for self.padding which is also 0 (which of course causes this same error). In the case of 0 being an acceptable default, that value should be acceptable by the receiving function determine_padding, which is where the error is raised: https://github.com/eriklindernoren/ML-From-Scratch/blob/a2806c6732eee8d27762edd6d864e0c179d8e9e8/mlfromscratch/deep_learning/layers.py#L718

Again, thank you for this repository. Amazing work.

krworks commented 4 years ago

Just to give a bit more context; I'm instantiating the PoolingLayer via: clf.add(MaxPooling2D(pool_shape=(2,2), stride=2, padding='same'))