// Subtract the mean so that vectors don"t just clump around common
// hypernyms
orig_vecs -= orig_vecs.mean(0)
// Delete the frame we built, we won"t need its indices again until the end
del retroframe
After Change
// Subtract the mean so that vectors don"t just clump around common
// hypernyms
for row_group in row_groups:
orig_vecs[row_group] -= orig_vecs[row_group].mean(0)
// Delete the frame we built, we won"t need its indices again until the end
del retroframe
vecs = orig_vecs
for iteration in range(iterations):
if verbosity >= 1:
print("Retrofitting: Iteration %s of %s" % (iteration+1, iterations))
vecs = sparse_csr.dot(vecs)
for row_group in row_groups:
orig_vecs[row_group] -= orig_vecs[row_group].mean(0)
// use sklearn"s normalize, because it normalizes in place and
// leaves zero-rows at 0
normalize(vecs, norm="l2", copy=False)