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.
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.weightorbatch['meta'][0]['mask'].
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.
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.
Manage your "Preview Keys" directly in the sidebar. No need to dig through JSON settings.
- 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).
visible-shape.previewKeys: A list of string keys that are prioritized when inspecting dictionaries. Defaults includeinput,data,label,target,img,image,x,y.
- VS Code 1.80.0 or newer.
- A Python environment with
torchand/ornumpyinstalled. - The standard Python extension for VS Code.
- NumPy Support: Added full support for
numpy.ndarrayinspection. - 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.
- Initial release with PyTorch support.
Enjoy clearer debugging!



