Skip to main content
torch.jstorch.jstorch.js
Getting StartedPlaygroundContact
Login
torch.jstorch.jstorch.js
Documentation
IntroductionType SafetyTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformance
IntroductionTraining DashboardsVisualizing TensorsGPU AccelerationInteractive InputsThemingStorybook
torch.js· 2026
LegalTerms of UsePrivacy Policy
  1. docs
  2. React UI
  3. Visualizing Tensors

Visualizing Tensors

Deep learning models are often "black boxes." react-ui provides high-level components to peer inside your models and understand their internal state.

Visualizing attention weights and activation maps

General Purpose: TensorViewer

The TensorViewer is the standard tool for inspecting any tensor. It automatically handles high-dimensional data by providing slicing controls.

import { TensorViewer } from '@torchjsorg/react-ui';

// Renders a heatmap of the tensor
<TensorViewer 
  data={activations} 
  colorScale="magma"
  showValues={false}
/>

Transformer Interpretability: AttentionViewer

Specifically designed for Transformer architectures, this component visualizes the relationship between tokens.

import { AttentionViewer } from '@torchjsorg/react-ui';

<AttentionViewer
  tensor={attentionWeights} // [Heads, Seq, Seq]
  tokens={['[CLS]', 'the', 'cat', 'sat', '[SEP]']}
  activeHead={0}
/>

Classification: SoftmaxHeatmap

Visualizes probability distributions from model outputs.

import { SoftmaxHeatmap } from '@torchjsorg/react-ui';

<SoftmaxHeatmap
  data={logits}
  labels={['Dog', 'Cat', 'Bird', 'Fish']}
  orientation="horizontal"
/>

Comparison of Visualization Components

ComponentTarget DataVisualization Type
TensorViewerAny Tensor2D Heatmap / Grid
AttentionViewerAttention WeightsConnection Graph
GpuPointCloudEmbeddings3D Interactive Space
GpuHistogramWeights / GradsFrequency Distribution

Advanced: HeatmapOverlay

For computer vision tasks, use HeatmapOverlay to project saliency maps or Class Activation Maps (CAM) directly onto input images.

<HeatmapOverlay
  imageSrc="/input.jpg"
  heatmap={saliencyTensor}
  opacity={0.6}
/>

Next Steps

  • GPU Acceleration - Learn about rendering large tensors efficiently.
  • Interactive Inputs - How to provide data to your models.
Previous
Training Dashboards
Next
GPU Acceleration