@ai-on-browser/data-analysis-models
Version:
Data analysis model package without any dependencies
106 lines (105 loc) • 3.28 kB
TypeScript
/**
* Simple RNN layer
*/
export default class RNNLayer extends Layer {
/**
* @param {object} config object
* @param {number} config.size Size of recurrent
* @param {string | object} [config.activation] Name of activation or activation layer object
* @param {boolean} [config.return_sequences] Return sequences or not
* @param {number[][] | Matrix | string} [config.w_x] Weight from input to sequence
* @param {number[][] | Matrix | string} [config.w_h] Weight from sequence to sequence
* @param {number[][] | Matrix | string} [config.b_x] Bias from input to sequence
* @param {number[][] | Matrix | string} [config.b_h] Bias from sequence to sequence
* @param {number} [config.sequence_dim] Dimension of the timesteps
*/
constructor({ size, activation, return_sequences, w_x, w_h, b_x, b_h, sequence_dim, ...rest }: {
size: number;
activation?: string | object;
return_sequences?: boolean;
w_x?: number[][] | Matrix | string;
w_h?: number[][] | Matrix | string;
b_x?: number[][] | Matrix | string;
b_h?: number[][] | Matrix | string;
sequence_dim?: number;
});
_size: number;
_unit: RNNUnitLayer;
_return_sequences: boolean;
_sequence_dim: 0 | 1;
calc(x: any): any;
_i: any[];
_o: any[];
grad(bo: any): any[] | Tensor<any>;
_grad_bptt(bo: any): any[] | Tensor<any>;
_bo: any[];
update(optimizer: any): void;
toObject(): {
w_x: string | any[][];
w_h: string | any[][];
b_x: string | any[][];
b_h: string | any[][];
activation: import("./index.js").PlainLayerObject;
type: string;
size: number;
return_sequences: boolean;
sequence_dim: number;
};
}
import Layer from './base.js';
declare class RNNUnitLayer extends Layer {
constructor({ layer, size, activation, w_x, w_h, b_x, b_h, ...rest }: {
[x: string]: any;
layer: any;
size: any;
activation?: string;
w_x?: any;
w_h?: any;
b_x?: any;
b_h?: any;
});
_size: any;
_w_x: Variable;
_w_h: Variable;
_b_x: Variable;
_b_h: Variable;
_z0: Matrix<number>;
_i: any[];
_z: any[];
_u: any[];
_bo: any[];
_bh: any[];
_activation: Layer;
calc(x: any, k: any): any;
grad(bo: any, k: any): any;
_grad_bptt(bo: any, k: any): any;
_diff_bptt(): void;
_dw_x: Matrix<number>;
_db_x: Matrix<number>;
_dw_h: Matrix<number>;
_db_h: Matrix<number>;
update(optimizer: any): void;
_update_bptt(optimizer: any): void;
toObject(): {
w_x: string | any[][];
w_h: string | any[][];
b_x: string | any[][];
b_h: string | any[][];
activation: import("./index.js").PlainLayerObject;
};
}
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[]): Matrix<any>;
toObject(): string | any[][];
}
export {};