Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible issue when computing unit norms #4

Open
AlexGonRo opened this issue Oct 24, 2017 · 1 comment
Open

Possible issue when computing unit norms #4

AlexGonRo opened this issue Oct 24, 2017 · 1 comment

Comments

@AlexGonRo
Copy link

I wanted to report a small bug I found when going a bit deeper into the code.

In trainer.py there is a function for computing the unit norm of the training data. This is the function:

def compute_unit_norms(X):
    norms = np.zeros(X[0].shape[1])
    for Xi in X:
        for i, ind in enumerate(Xi.indices):
            norms[ind] = Xi.data[i] ** 2

    norms = norms ** .5
    norms[np.where(norms == 0)] = 1.0
    return norms.astype('float32')

My question here is the following: aren't you missing a += instead of a =inside the for loop?. The forth line of the code then would be

norms[ind] += Xi.data[i] ** 2

And thank you guys for sharing the library :)

@Refefer
Copy link
Owner

Refefer commented Oct 24, 2017

Thanks for the report and good question; I don't remember off the top of my head. Let me take a look at it tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants