From eca77ab1398ac479827efa287a323dd0257afe59 Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Sat, 25 May 2024 17:07:15 +0800 Subject: [PATCH] [system-a] `linear` --- TODO.md | 3 ++- src/system-a/toys/linear.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/system-a/toys/linear.ts diff --git a/TODO.md b/TODO.md index 55ff98d..c2eb7fa 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ # system-a -[system-a] `linear` +[system-a] test `linear` +[system-a] `relu` # the-book diff --git a/src/system-a/toys/linear.ts b/src/system-a/toys/linear.ts new file mode 100644 index 0000000..107afa5 --- /dev/null +++ b/src/system-a/toys/linear.ts @@ -0,0 +1,7 @@ +import type { Tensor } from "../tensor/index.js" +import { dot } from "./dot.js" +import { add } from "./toys.js" + +export function linear(t: Tensor): (weight: Tensor, bias: Tensor) => Tensor { + return (weight, bias) => add(dot(weight, t), bias) +}