---
title: "TensorView"
---
<!-- DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/docs/website.rs -->

⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
A view on a tensor of any dimensionality.

## Properties

### `slice_selection`
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`
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`
Configures how the selected slice should fit into the view.

## API reference links
 * 🐍 [Python API docs for `TensorView`](https://ref.rerun.io/docs/python/stable/common/blueprint_views#rerun.blueprint.views.TensorView)

## Example

### Use a blueprint to create a TensorView.

```python
"""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)
```

<picture data-inline-viewer="snippets/views/tensor">
  <source media="(max-width: 480px)" srcset="https://static.rerun.io/tensor_view/04158807b970c16af7922698389b239b0575c436/480w.png">
  <source media="(max-width: 768px)" srcset="https://static.rerun.io/tensor_view/04158807b970c16af7922698389b239b0575c436/768w.png">
  <source media="(max-width: 1024px)" srcset="https://static.rerun.io/tensor_view/04158807b970c16af7922698389b239b0575c436/1024w.png">
  <source media="(max-width: 1200px)" srcset="https://static.rerun.io/tensor_view/04158807b970c16af7922698389b239b0575c436/1200w.png">
  <img src="https://static.rerun.io/tensor_view/04158807b970c16af7922698389b239b0575c436/full.png">
</picture>


## Visualized archetypes

* [`Tensor`](https://rerun.io/docs/reference/types/archetypes/tensor.md)

