UNPKG

@ai-on-browser/data-analysis-models

Version:

Data analysis model package without any dependencies

194 lines (193 loc) 6.4 kB
/** * LSTM layer */ export default class LSTMLayer extends Layer { /** * @param {object} config object * @param {number} config.size Size of output * @param {boolean} [config.return_sequences] Return sequences or not * @param {number[][] | Matrix | string} [config.w_z] Weight of z from input to sequence * @param {number[][] | Matrix | string} [config.w_in] Weight of 'in' from input to sequence * @param {number[][] | Matrix | string} [config.w_for] Weight of 'for' from input to sequence * @param {number[][] | Matrix | string} [config.w_out] Weight of 'out' from input to sequence * @param {number[][] | Matrix | string} [config.r_z] Weight of z from sequence to sequence * @param {number[][] | Matrix | string} [config.r_in] Weight of 'in' from sequence to sequence * @param {number[][] | Matrix | string} [config.r_for] Weight of 'for' from sequence to sequence * @param {number[][] | Matrix | string} [config.r_out] Weight of 'out' from sequence to sequence * @param {number[][] | Matrix | string} [config.p_in] p_in * @param {number[][] | Matrix | string} [config.p_for] p_for * @param {number[][] | Matrix | string} [config.p_out] p_out * @param {number[][] | Matrix | string} [config.b_z] Bias of z of output * @param {number[][] | Matrix | string} [config.b_in] Bias of 'in' of output * @param {number[][] | Matrix | string} [config.b_for] Bias of 'for' of output * @param {number[][] | Matrix | string} [config.b_out] Bias of 'out' of output * @param {number} [config.sequence_dim] Dimension of the timesteps */ constructor({ size, return_sequences, w_z, w_in, w_for, w_out, r_z, r_in, r_for, r_out, p_in, p_for, p_out, b_z, b_in, b_for, b_out, sequence_dim, ...rest }: { size: number; return_sequences?: boolean; w_z?: number[][] | Matrix | string; w_in?: number[][] | Matrix | string; w_for?: number[][] | Matrix | string; w_out?: number[][] | Matrix | string; r_z?: number[][] | Matrix | string; r_in?: number[][] | Matrix | string; r_for?: number[][] | Matrix | string; r_out?: number[][] | Matrix | string; p_in?: number[][] | Matrix | string; p_for?: number[][] | Matrix | string; p_out?: number[][] | Matrix | string; b_z?: number[][] | Matrix | string; b_in?: number[][] | Matrix | string; b_for?: number[][] | Matrix | string; b_out?: number[][] | Matrix | string; sequence_dim?: number; }); _size: number; _unit: LSTMUnitLayer; _return_sequences: boolean; _sequence_dim: 0 | 1; calc(x: any): any; _x: any[]; _y: any[]; grad(bo: any): any[] | Tensor; _grad_bptt(bo: any): any[] | Tensor; _bo: any[]; update(optimizer: any): void; toObject(): { w_z: string | any[][]; w_in: string | any[][]; w_for: string | any[][]; w_out: string | any[][]; r_z: string | any[][]; r_in: string | any[][]; r_for: string | any[][]; r_out: string | any[][]; p_in: string | any[][]; p_for: string | any[][]; p_out: string | any[][]; b_z: string | any[][]; b_in: string | any[][]; b_for: string | any[][]; b_out: string | any[][]; type: string; size: number; return_sequences: boolean; sequence_dim: number; }; } import Layer from './base.js'; declare class LSTMUnitLayer extends Layer { constructor({ layer, size, w_z, w_in, w_for, w_out, r_z, r_in, r_for, r_out, p_in, p_for, p_out, b_z, b_in, b_for, b_out, ...rest }: { [x: string]: any; layer: any; size: any; w_z?: any; w_in?: any; w_for?: any; w_out?: any; r_z?: any; r_in?: any; r_for?: any; r_out?: any; p_in?: any; p_for?: any; p_out?: any; b_z?: any; b_in?: any; b_for?: any; b_out?: any; }); _size: any; _w_z: Variable; _w_in: Variable; _w_for: Variable; _w_out: Variable; _r_z: Variable; _r_in: Variable; _r_for: Variable; _r_out: Variable; _p_in: Variable; _p_for: Variable; _p_out: Variable; _b_z: Variable; _b_in: Variable; _b_for: Variable; _b_out: Variable; _c0: Matrix<number>; _y0: Matrix<number>; _x: any[]; _c: any[]; _y: any[]; _ob: any[]; _o: any[]; _fb: any[]; _f: any[]; _ib: any[]; _i: any[]; _zb: any[]; _z: any[]; _bo: any[]; _dy: any[]; _do: any[]; _dc: any[]; _df: any[]; _di: any[]; _dz: any[]; _sigmoid(x: any): Matrix<number>; _grad_sigmoid(x: any, y: any): Matrix<number>; _tanh(x: any): Matrix<number>; _grad_tanh(x: any): Matrix<number>; calc(x: any, k: any): any; grad(bo: any, k: any): any; _grad_bptt(bo: any, t: any): any; _diff_bptt(): void; _dw_z: Matrix<number>; _dw_in: Matrix<number>; _dw_out: Matrix<number>; _dw_for: Matrix<number>; _db_z: Matrix<number>; _db_in: Matrix<number>; _db_out: Matrix<number>; _db_for: Matrix<number>; _dp_out: Matrix<number>; _dr_z: Matrix<number>; _dr_in: Matrix<number>; _dr_out: Matrix<number>; _dr_for: Matrix<number>; _dp_in: Matrix<number>; _dp_for: Matrix<number>; update(optimizer: any): void; toObject(): { w_z: string | any[][]; w_in: string | any[][]; w_for: string | any[][]; w_out: string | any[][]; r_z: string | any[][]; r_in: string | any[][]; r_for: string | any[][]; r_out: string | any[][]; p_in: string | any[][]; p_for: string | any[][]; p_out: string | any[][]; b_z: string | any[][]; b_in: string | any[][]; b_for: string | any[][]; b_out: string | any[][]; }; } import Tensor from '../../../util/tensor.js'; import Matrix from '../../../util/matrix.js'; declare class Variable { constructor(layer: any, value: any, sizes: any); _layer: any; _sizes: any; _name: string; _value: Matrix<any>; get name(): string; get value(): Matrix<any>; get sizes(): number[]; get(...sizes: any[]): any; toObject(): string | any[][]; } export {};