spark.SparkExposedValue
export interface SparkExposedValue<T = unknown> {
/**
* Current value.
*
* @readonly
*/
readonly value: T;
/**
* Set the value in the worker.
*
* This sends the new value to the worker and updates the UI.
*
* @param value - New value to set
*/
set(value: T): void;
/**
* History of all values this binding has had.
*
* Useful for plotting training curves. Each entry has the value
* and the timestamp it was set.
*
* @readonly
*/
readonly history: Array<{ value: T; timestamp: number }>;
}T- readonly
value(T) - – Current value.
set((value: T) => void)- – Set the value in the worker. This sends the new value to the worker and updates the UI.
- readonly
history(Array<{ value: T; timestamp: number }>) - – History of all values this binding has had. Useful for plotting training curves. Each entry has the value and the timestamp it was set.
A value exposed from the worker to the UI.
Provides access to the current value, ability to set it, and a history of all values for visualization.
Examples
const s = spark.use(torch);
// Access current value
console.log(s.loss.value); // 0.342
// Set value (sends to worker)
s.lr.set(0.001);
// View history (for charts)
console.log(s.loss.history); // [{ value: 0.5, timestamp: ... }, ...]