TensorView
A view on a tensor of any dimensionality.
Properties properties
slice_selection
sliceselection
How to select the slice of the tensor to show.
width
: Which dimension to map to width.height
: Which dimension to map to height.indices
: Selected indices for all other dimensions.slider
: Any dimension listed here will have a slider for the index.
scalar_mapping
scalarmapping
Configures how scalars are mapped to color.
mag_filter
: Filter used when zooming in on the tensor.colormap
: How scalar values map to colors.gamma
: Gamma exponent applied to normalized values before mapping to color.
view_fit
viewfit
Configures how the selected slice should fit into the view.
API reference links api-reference-links
Example example
Use a blueprint to create a TensorView. use-a-blueprint-to-create-a-tensorview
"""Use a blueprint to show a tensor view."""
import numpy as np
import rerun as rr
import rerun.blueprint as rrb
rr.init("rerun_example_tensor", spawn=True)
tensor = np.random.randint(0, 256, (32, 240, 320, 3), dtype=np.uint8)
rr.log("tensor", rr.Tensor(tensor, dim_names=("batch", "x", "y", "channel")))
blueprint = rrb.Blueprint(
rrb.TensorView(
origin="tensor",
name="Tensor",
# Explicitly pick which dimensions to show.
slice_selection=rrb.TensorSliceSelection(
# Use the first dimension as width.
width=1,
# Use the second dimension as height and invert it.
height=rr.TensorDimensionSelection(dimension=2, invert=True),
# Set which indices to show for the other dimensions.
indices=[
rr.TensorDimensionIndexSelection(dimension=2, index=4),
rr.TensorDimensionIndexSelection(dimension=3, index=5),
],
# Show a slider for dimension 2 only. If not specified, all dimensions in `indices` will have sliders.
slider=[2],
),
# Set a scalar mapping with a custom colormap, gamma and magnification filter.
scalar_mapping=rrb.TensorScalarMapping(colormap="turbo", gamma=1.5, mag_filter="linear"),
# Fill the view, ignoring aspect ratio.
view_fit="fill",
),
collapse_panels=True,
)
rr.send_blueprint(blueprint)