From dc538733da8d49e7240d00fb05517053076fe261 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 16 Dec 2023 11:06:03 -0800 Subject: Define vector outer product (nnMatrixMulOuter), which removes the need to transpose layer inputs during training. --- src/lib/include/neuralnet/matrix.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/lib/include') diff --git a/src/lib/include/neuralnet/matrix.h b/src/lib/include/neuralnet/matrix.h index f80b985..4cb0d25 100644 --- a/src/lib/include/neuralnet/matrix.h +++ b/src/lib/include/neuralnet/matrix.h @@ -56,13 +56,20 @@ void nnMatrixInitConstant(nnMatrix*, R value); /// Multiply two matrices. void nnMatrixMul(const nnMatrix* left, const nnMatrix* right, nnMatrix* out); -/// Multiply two matrices, row variant. +/// Multiply two matrices, row-by-row variant. /// -/// This function multiples two matrices row-by-row instead of row-by-column. -/// nnMatrixMul(A, B, O) == nnMatrixMulRows(A, B^T, O). +/// This function multiples two matrices row-by-row instead of row-by-column, +/// which is equivalent to regular multiplication after transposing the right +/// hand matrix. +/// +/// nnMatrixMul(A, B, O) == nnMatrixMulRows(A, B^T, O). void nnMatrixMulRows( const nnMatrix* left, const nnMatrix* right, nnMatrix* out); +/// Compute the outer product of two vectors. +void nnMatrixMulOuter( + const nnMatrix* left, const nnMatrix* right, nnMatrix* out); + /// Matrix multiply-add. /// /// out = left + (right * scale) -- cgit v1.2.3