ml-basic
Version:
Lightweight, zero dependency, machine learning library
27 lines (26 loc) • 822 B
TypeScript
import { Activator } from "../lib/functions";
import Matrix from "../lib/matrix";
import Layer from "./layer";
export type LoopParams = {
input: [number, number];
output: number;
/**
* @default {@link Sigmoid}
*/
activation?: Activator;
};
export default abstract class LoopLayer<T extends string = ''> extends Layer {
state: Matrix;
cache: {
[key in T]: Matrix[];
};
index: number;
constructor({ input, output, activation }: LoopParams);
abstract clear(): void;
abstract forward(input: Matrix, output: boolean): Matrix | void;
abstract backward(loss: Matrix): Matrix;
store(key: T, value: Matrix): void;
get(key: T, offset?: number): Matrix;
propagate(input: Matrix): Matrix;
backPropagate(_1: Matrix, _2: Matrix, loss: Matrix): Matrix;
}