Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. SparkExposedValue

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
readonlyvalue(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.
readonlyhistory(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: ... }, ...]
Previous
SparkExposedFunction
Next
SparkLoadOptions