Giter Club home page Giter Club logo

cnn-from-scratch's People

Contributors

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

Watchers

 avatar  avatar

cnn-from-scratch's Issues

MaxPoolingLayer back_prop return incorrectly indented

Unless I'm missing something obvious, I think the return statement on line 109 in utils.py is indented one tab too far.

When debugging, I got unexpected results from this function (most of the grads passed back to the convolution layer were 0). Stepping through, I realized I was getting kicked out of the loops far sooner than expected. Then, I noticed where the return statement is indented.

def back_prop(self, dE_dY):
    dE_dk = np.zeros(self.image.shape)
    for patch,h,w in self.patches_generator(self.image):
        image_h, image_w, num_kernels = patch.shape
        max_val = np.amax(patch, axis=(0,1))

        for idx_h in range(image_h):
            for idx_w in range(image_w):
                for idx_k in range(num_kernels):
                    if patch[idx_h,idx_w,idx_k] == max_val[idx_k]:
                        dE_dk[h*self.kernel_size+idx_h, w*self.kernel_size+idx_w, idx_k] = dE_dY[h,w,idx_k]
        return dE_dk

It kicks you out after finding the max for the first patch. Interestingly, the model as-is still converges.

P.S. I've found this repository very helpful

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.