How do scalar user and item factors form all pairwise products?
outer flattens both inputs and multiplies every left value by every right value to form a grid.
numpy.outer in practice
Two users and three items produce six scores. At a million users, estimate the grid size and compute only the required blocks.
import numpy as np
np.outer([2,3],[1,4,5])Result [[2, 8, 10], [3, 12, 15]]
中文
怎样构造所有用户与商品标量因子的两两乘积?
outer 将两个输入展平,把每个左值与每个右值相乘,结果为二维网格。
numpy.outer 算例
两名用户和三件商品产生六个分数。扩展到百万用户时,先估算完整网格大小,按所需行列分块计算。
import numpy as np
np.outer([2,3],[1,4,5])结果 [[2, 8, 10], [3, 12, 15]]