@astermind/astermind-elm
Version:
JavaScript Extreme Learning Machine (ELM) library for browser and Node.js.
53 lines (52 loc) • 1.82 kB
TypeScript
import { ELM } from '../core/ELM';
import { ELMConfig, Activation } from '../core/ELMConfig';
export declare class EncoderELM {
elm: ELM;
private config;
private online?;
private onlineInputDim?;
private onlineOutputDim?;
constructor(config: ELMConfig);
/** Batch training for string → dense vector mapping. */
train(inputStrings: string[], targetVectors: number[][]): void;
/** Encode a string into a dense feature vector using the trained model. */
encode(text: string): number[];
/**
* Begin an online OS-ELM run for string→vector encoding.
* Provide outputDim and either inputDim OR a sampleText we can encode to infer inputDim.
*/
beginOnline(opts: {
outputDim: number;
inputDim?: number;
sampleText?: string;
hiddenUnits?: number;
ridgeLambda?: number;
activation?: Activation;
weightInit?: 'uniform' | 'xavier' | 'he';
forgettingFactor?: number;
seed?: number;
}): void;
/**
* Online partial fit with *pre-encoded* numeric vectors.
* If not initialized, this call seeds the model via `init`, else it performs an `update`.
*/
partialTrainOnlineVectors(batch: Array<{
x: number[];
y: number[];
}>): void;
/**
* Online partial fit with raw texts and dense numeric targets.
* Texts are encoded + normalized internally.
*/
partialTrainOnlineTexts(batch: Array<{
text: string;
target: number[];
}>): void;
/**
* Finalize the online run by publishing learned weights into the standard ELM model.
* After this, the normal encode() path works unchanged.
*/
endOnline(): void;
loadModelFromJSON(json: string): void;
saveModelAsJSONFile(filename?: string): void;
}