fn
addr
→Tensoraddr(input: Tensor, vec1: Tensor, vec2: Tensor, beta: float = ..., alpha: float = ...)Rank-1 update of a matrix by an outer product (BLAS-2 ger).
Computes
,
i.e. updates the matrix input by adding the (scaled) outer product
of two vectors. The classical BLAS ger routine.
Parameters
inputTensorAccumulator matrix of shape
(M, N).vec1TensorFirst vector of length
M.vec2TensorSecond vector of length
N.betafloatScalar multiplier on
input. Defaults to 1.0.alphafloatScalar multiplier on the outer product. Defaults to
1.0.Returns
TensorUpdated matrix of shape (M, N).
Notes
Element-wise:
The outer product is a rank-1 matrix, so this update can be used to build rank-1 corrections in optimisation algorithms (Broyden / BFGS).
Examples
>>> import lucid
>>> M = lucid.zeros((2, 3))
>>> u = lucid.tensor([1., 2.])
>>> v = lucid.tensor([3., 4., 5.])
>>> lucid.addr(M, u, v)
Tensor([[ 3., 4., 5.],
[ 6., 8., 10.]])