Tensor #
Tensor inspection widgets for the Lean infoview.
Import NN.Widgets or NN.Widgets.Core.Tensor to inspect values through ProofWidgets' #html
command. Previews read bounded prefixes and leading slices; the statistics panel scans the whole
tensor. Rendering a value does not prove a property of it.
Main definitions #
tensorHtml: shape-aware renderer for typed tensors.packedTensorHtml: the same renderer for shape-erased tensors.tensorStatsHtml: compact scalar summary (min/max/mean/norms).#tensor_view,#anytensor_view,#tensor_stats_view: command entry points.
Element renderer for #tensor_view. The default uses ToString; specialized instances can add
tooltips, units, or compact formatting.
- render : α → ProofWidgets.Html
Instances
Default element renderer for #tensor_view, using ToString.
Read only the requested prefix, without converting the full backing buffer.
Instances For
Render a 1D tensor as a clipped single-row table.
Instances For
Render a 2D tensor as a clipped grid table.
Instances For
First maxElems entries of a tensor in row-major order, with a marker when there are more.
Truncating matters here: a widget that tried to print a full tensor would hang the editor on anything of realistic size.
Instances For
Render a tensor as HTML.
Vectors and matrices use clipped tables. Higher-rank tensors show bounded leading slices, with a flat preview when the recursion depth is exhausted.
Instances For
Runtime Wrappers #
Render a Spec.SomeTensor with the same UI as tensorHtml.
Instances For
Stats #
#tensor_stats_view t computes extrema, mean, and norms using the scalar's Context operations.
Unlike the clipped previews, it materializes and scans every entry.
Numeric summary panel: shape, size, extrema, mean, and the three usual norms.
Instances For
Render extrema, mean, and norms, scanning every entry with the scalar's arithmetic.