Visible Shape
Visible Shape is a specialized VS Code extension for PyTorch and NumPy developers. It provides a dedicated "Watch" view that automatically extracts and displays tensor/array attributes (shape, dtype, device, etc.) and recursively searches for data deeply nested within lists, dictionaries, and custom objects.
It is designed to fix the annoyance of digging through the standard Debug Variables view just to see x.shape.
Features
1. Smart Data Inspection
Automatically detects torch.Tensor and numpy.ndarray objects and displays their key attributes. It is robust enough to handle:
- PyTorch Tensors: Displays
shape, dtype, device, requires_grad.
- NumPy Arrays: Displays
shape, dtype, and identifies them as (NumPy Array).
- Containers: Works with
[x, y], {'input': x, 'label': y}, and custom objects.
- Deeply Nested Structures: Finds data deep inside complex structures like
model.layer1.weight or batch['meta'][0]['mask'].

2. "Silent" Quick Add
Add variables to the watch list instantly without breaking your flow:
- Select & Add: Select a variable name in the editor and click the
+ button in the sidebar. It adds instantly—no popup dialogs.
- Context Menu: Right-click a selection in the editor or a variable in the standard Debug View and select
Add Variable.

3. Deep Search & Preview Keys
When watching a complex dictionary (e.g., a batch from a DataLoader), Visible Shape can prioritize specific keys (like data, input, img) to show you what matters first.
- Smart Preview: If a dict contains a key in your "Preview Keys" list, it shows that value first.
- Deep Search: It recursively searches (up to depth 4) to find the first tensor/array inside complex objects.
4. Visual Configuration
Manage your "Preview Keys" directly in the sidebar. No need to dig through JSON settings.

Usage
- Start Debugging: Run your Python code (with PyTorch or NumPy) in VS Code's debugger.
- Open View: Click the Visible Shape icon in the Activity Bar (
[...] array symbol).
- Add Variables:
- Method A: Highlight a variable in your code, right-click, and choose Add Variable.
- Method B: Click the
+ icon in the Tensor Watch view title.
- Inspect: Expand the variable in the view to see its shape and attributes.
- Configure: Use the Preview Keys view below to add keys you commonly use (e.g.,
mask, bbox).
Configuration
visible-shape.previewKeys: A list of string keys that are prioritized when inspecting dictionaries. Defaults include input, data, label, target, img, image, x, y.
Requirements
- VS Code 1.80.0 or newer.
- A Python environment with
torch and/or numpy installed.
- The standard Python extension for VS Code.
Release Notes
0.1.0
- NumPy Support: Added full support for
numpy.ndarray inspection.
- Improved UI: New activity bar icon and dedicated "Preview Keys" view.
- Context Menus: Added "Add Variable" to editor and debug context menus.
- Recursive Search: Enhanced support for finding tensors inside Custom Objects.
0.0.1 (Beta)
- Initial release with PyTorch support.
Enjoy clearer debugging!
| |