normalize: Normalize all word vectors to the unit length 1.

View source: R/01-basic.R

normalizeR Documentation

Normalize all word vectors to the unit length 1.

Description

L2-normalization (scaling to unit euclidean length): the norm of each vector in the vector space will be normalized to 1. It is necessary for any linear operation of word vectors.

Usage

normalize(x)

Arguments

x

A wordvec (data.table) or embed (matrix), see data_wordvec_load().

Details

R code inside:

  • Vector: vec / sqrt(sum(vec^2))

  • Matrix: mat / sqrt(rowSums(mat^2))

Value

A wordvec (data.table) or embed (matrix) with normalized word vectors.

Download

Download pre-trained word vectors data (.RData): https://psychbruce.github.io/WordVector_RData.pdf

See Also

as_wordvec() / as_embed()

load_wordvec() / load_embed()

data_transform()

data_wordvec_subset()

Examples

d = normalize(demodata)
# the same: d = as_wordvec(demodata, normalize=TRUE)


PsychWordVec documentation built on Aug. 21, 2025, 5:53 p.m.