Coder Social home page Coder Social logo

Comments (5)

felixmaximilian avatar felixmaximilian commented on May 28, 2024

A new insight:
In ffm_sgc.c, when p_p or p_n "overflows" (running out of the reasonable range), Ai[p_p] is 0, which is why it'll always be smaller then Ai[p_n] which is why it'll be increased again in the if statement, while the reason that another iteration over the while loop has to be done is in fact p_n (because p_n < Ap[sample_row_n + 1] evaluates to True ).
ffm_sgc.c:

int p_n = Ap[sample_row_n];
int p_p = Ap[sample_row_p];
while (p_n < Ap[sample_row_n + 1] || p_p < Ap[sample_row_p + 1]) {
  double grad = 0;
  int i_to_update = Ai[p_p] <= Ai[p_n] ? Ai[p_p] : Ai[p_n];
  double theta_w = coef->w->data[i_to_update];
  // incrementing the smaller index or both if equal
  if (Ai[p_p] == i_to_update) {
    grad = Ax[p_p];
    p_p++;
  }
  if (Ai[p_n] == i_to_update) {
    grad -= Ax[p_n];
    p_n++;
  }

The above PR fixes this issue. Feel free to make it more beautiful :-)

from fastfm.

ibayer avatar ibayer commented on May 28, 2024

Regarding the difference between the python and C code, 3) in your first comment.
The C code expect the data in row major order while the python code expects column major (csc_matrix). I have to check in detail if I'm not overlooking something. I mean, a bug like this should really trigger some of the tests...

from fastfm.

ibayer avatar ibayer commented on May 28, 2024

@ibayer the choice of column / row major matrices is correct but was hard to understand (PR).

from fastfm.

felixmaximilian avatar felixmaximilian commented on May 28, 2024

The mentioned problem is fixed by @ibayer 's PR #14. Thanks for your help!

from fastfm.

ibayer avatar ibayer commented on May 28, 2024

@felixmaximilian I have closed your PR for fastFM-core . I have just know updated #63 fastFM-core in fastFM so that the BPR should now work from the Python interface too. Just open a new issue if you run into any other problems. And thanks again for tracing the problem back to it's roots.

from fastfm.

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.