@ai-on-browser/data-analysis-models
Version:
Data analysis model package without any dependencies
93 lines (92 loc) • 3.06 kB
TypeScript
/**
* Exception for neuralnetwork layer class
*/
export class NeuralnetworkLayerException extends Error {
/**
* @param {string} message Error message
* @param {*} value Some value
*/
constructor(message: string, value: any);
value: any;
}
/**
* Neuralnetwork layer
*/
export default class Layer {
/**
* Returns layer from JSON.
* @param {import("./index").PlainLayerObject} obj Object represented a layer
* @returns {Layer} Layer
*/
static fromObject(obj: import("./index").PlainLayerObject): Layer;
/**
* Regist layer class.
* @param {string} [name] Name of the layer
* @param {Layer} [cls] Layer class
*/
static registLayer(name?: string, cls?: Layer): void;
/**
* List of names of other layers dependent on this layer.
* @type {string[]}
*/
get dependentLayers(): string[];
/**
* Bind pre-condition values.
* @param {object} values Binding object
* @param {Matrix | Tensor | {[key: string]: Matrix | Tensor}} values.input Input data for neuralnetwork
* @param {Matrix} [values.supervisor] Supervisor data
* @param {number} values.n Data count
* @param {*} values.rest Some other values
*/
bind(values: {
input: Matrix | Tensor | {
[key: string]: Matrix | Tensor;
};
supervisor?: Matrix;
n: number;
rest: any;
}): void;
/**
* Returns calculated values.
* @param {...(Matrix | Tensor)} x Input values
* @returns {Matrix | Tensor | Array<Matrix | Tensor>} Output values
*/
calc(...x: (Matrix | Tensor)[]): Matrix | Tensor | Array<Matrix | Tensor>;
/**
* Returns gradient values.
* @param {...(Matrix | Tensor)} bo Input value of backpropagation
* @returns {Matrix | Tensor | Array<Matrix | Tensor>} Output value of backpropagation
*/
grad(...bo: (Matrix | Tensor)[]): Matrix | Tensor | Array<Matrix | Tensor>;
/**
* Update parameters.
* @param {{lr: number, delta: (function (string, Matrix): Matrix)}} optimizer Optimizer for this layer
*/
update(optimizer: {
lr: number;
delta: ((arg0: string, arg1: Matrix) => Matrix);
}): void;
/**
* Returns object of this layer.
* @returns {import("./index").PlainLayerObject} Object represented this layer
*/
toObject(): import("./index").PlainLayerObject;
}
/**
* Base class for Flow-based generative model
*/
export class FlowLayer extends Layer {
/**
* Returns inverse values.
* @param {...(Matrix | Tensor)} y Input value of inverse calculation
* @returns {Matrix | Tensor | Array<Matrix | Tensor>} Output value of inverse calculation
*/
inverse(...y: (Matrix | Tensor)[]): Matrix | Tensor | Array<Matrix | Tensor>;
/**
* Returns determinant of the Jacobian.
* @returns {number} Determinant of the Jacobian
*/
jacobianDeterminant(): number;
}
import Matrix from '../../../util/matrix.js';
import Tensor from '../../../util/tensor.js';