Giter Club home page Giter Club logo

Comments (3)

vmirly avatar vmirly commented on May 24, 2024

So I think you are talking about this equation:
image

The equation is correct.
$x^p$ is the padded input vector, with $p$ zeros on each side of the vector. $k$ is the index of the summation. Let's assume n=8, m=3, and p=1, then x_p will have size 10, and the output elements are as follows:

  • y[0] => np.sum(x_p[:3:-1] * w[:])
  • y[1] => np.sum(x_p[1:4:-1] * w[:])
  • y[2] => np.sum(x_p[2:5:-1] * w[:])
  • ...

so even if you change the padding, for example p=5; x_p will be padded with 5 zeros on left and ride, but the indexes in the above examples will stay the same:

  • y[0] => np.sum(x_p[:3:-1] * w[:])
  • y[1] => np.sum(x_p[1:4:-1] * w[:])
  • y[2] => np.sum(x_p[2:5:-1] * w[:])
  • ...

The only difference is that x_p here has size n+2*p=18 (instead of 10).

from python-machine-learning-book-2nd-edition.

tlin40 avatar tlin40 commented on May 24, 2024

Thank you for the quick response! Somehow in my mind I just ignored zeros padded on left of x_p and started from x_p[0+p] (the first element of non-zero x_p).

There's another thing I've noticed: if y[i], x_p[i], w[i] are all meant to be zero-indexed vectors, x_p[i+m-k] probably should be x_p[i+m-1-k], so that when y[i=0] and k=m-1, x_p[0] is the leftmost element to be used instead of x_p[1].

from python-machine-learning-book-2nd-edition.

vmirly avatar vmirly commented on May 24, 2024

Yes you are right, the current formula gives the following for i=0:

i=0 :: y[0] = x_p[0+3-0] . w[0]  +  x_p[0+3-1] . w[1]   +   x_p[0+3-2] . w[2]
            = x_p[3] . w[0].     +   x_p[2] . w[1]      +  x_p[1] . w[2] 

which is not correct, and instead should have been:

i=0 :: y[0] = x_p[0+3-1-0] . w[0]  +  x_p[0+3-1-1] . w[1]   +   x_p[0+3-1-2] . w[2]
            = x_p[2] . w[0]        +   x_p[1] . w[1]        +    x_p[0] . w[2] 

Thanks for bringing this to our attention. I did not realize this issue

from python-machine-learning-book-2nd-edition.

Related Issues (20)

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.