:orphan:

================
Usage Examples
================

This page contains example visualizations using VisualTorch. Click on any image to see the full image and source code.


.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. thumbnail-parent-div-close

.. raw:: html

    </div>

============
Flow
============

These examples cover flow-style visualization


.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of 2D view">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_2d_view_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_2d_view`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">2D View</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of basic custom model">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_basic_custom_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_basic_custom`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Basic Custom</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of basic sequential model">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_basic_sequential_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_basic_sequential`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Basic Sequential</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Instead of hand-building a color_map entry for every layer type, pick a named palette - it&#x27;s used as the fallback fill color for any layer type not given an explicit color_map override. A handful of the built-in palettes are shown below; see visualtorch.PALETTES.keys() for the full list.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_color_palettes_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_color_palettes_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Color Palettes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom color. The synthetic input box can be recolored too, keyed by visualtorch.Input in color_map just like any real layer type - left uncustomized, it would default to the same color as Conv2d here, since both would otherwise claim the same slot in the color wheel.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_custom_color_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_custom_color`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Color</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Change the color transparency">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_custom_opacity_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_custom_opacity`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Opacity</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom orientation for layers without real spatial/channel structure (a 1D shape, or a 2D shape like an RNN/attention layer&#x27;s (seq_len, hidden_size)).">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_custom_orientation_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_custom_orientation`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Orientation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom shading">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_custom_shading_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_custom_shading`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Shading</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom spacing">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_custom_spacing_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_custom_spacing`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Spacing</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="background_fill isn&#x27;t limited to plain white - it also accepts a transparent color (e.g. (0, 0, 0, 0)), useful for dropping a figure onto a paper/slide without a white box around it, or an opaque dark color for a nicer look on dark-mode pages.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_dark_background_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_dark_background`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dark Background</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="flow_view&#x27;s box size has two independent levers: scale_xy scales each box&#x27;s spatial (width/height) extent, and scale_z scales its depth (channel count). Both are clamped by min_xy/``max_xy`` and min_z/``max_z`` - if a box&#x27;s computed size is already sitting at one of those floors, raising the corresponding scale won&#x27;t visibly change anything until it pushes past that floor. With the defaults (``min_z=10``, scale_z=0.1), any layer with fewer than 100 channels is already clamped to the same minimum depth - so bumping scale_z alone may look like it did nothing unless you push it far enough to clear that floor.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_higher_resolution_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_higher_resolution_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Higher Resolution</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualize some layers only. type_ignore hides layer types you don&#x27;t care about (here, ReLU and Flatten); show_input=False is the same idea applied to the synthetic input box itself - both trim the diagram down to just the layers worth looking at.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_ignore_layers_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_ignore_layers`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Ignore Layers</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same Inception-style block as the graph style&#x27;s multi-branch example - four parallel branches (a plain Conv2d+BatchNorm2d, a 1x1-then-3x3 conv, a 1x1-then-5x5 conv, and a max-pool-then-1x1-conv) that all read the same input and merge into a shared projection layer - rendered in flow style instead.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_inception_block_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_inception_block_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Branch Merge (Inception-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same two-branch model as the graph style&#x27;s multi-input example - an image branch (Conv2d + global pooling) and a tabular-vector branch (a small MLP), merged by concatenation before a shared head - rendered in flow style instead.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_multi_input_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_multi_input_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Input Model (Siamese-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A leaf layer&#x27;s forward() doesn&#x27;t always return a single tensor - nn.LSTM returns (output, (h_n, c_n)): the full sequence of hidden states, plus the final hidden and cell states. With show_dimension=True, every one of those output tensors&#x27; shapes is printed, not just the first, so a downstream layer that consumes h_n instead of output (as this model does) doesn&#x27;t leave its actual input shape unaccounted for.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_multi_output_shapes_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_multi_output_shapes_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Output Layer Shapes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same real, torchvision-provided resnet18 architecture as the graph style&#x27;s example - 8 residual blocks across 4 stages, with a projection shortcut where channels/spatial size change - rendered in flow style instead.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_resnet18_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_resnet18_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ResNet-18</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of a classic ResNet-style residual block: Conv2d + BatchNorm2d, twice, with a plain identity shortcut around them and a final ReLU.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_residual_block_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_residual_block_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Residual Block</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same small U-Net as the graph style&#x27;s example, rendered in flow style instead - the contracting-then-expanding channel/spatial shape naturally produces the classic U-Net silhouette.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_unet_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_unet_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">U-Net</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same small Vision Transformer as the graph style&#x27;s ViT example, rendered in flow style instead. This is a deep, narrow model (many similarly-sized sequential layers), which flow&#x27;s volumetric look tends to render busier/harder to visually parse than graph - included here for completeness, but graph is the clearer choice for this kind of architecture.">

.. only:: html

  .. image:: /usage_examples/flow/images/thumb/sphx_glr_plot_vit_flow_thumb.png
    :alt:

  :doc:`/usage_examples/flow/plot_vit_flow`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vision Transformer (ViT)</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

============
Graph
============

These examples cover visualization via graph view


.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of basic dense model. No color_map is passed here, so each layer type is assigned a color automatically from a colorblind-safe default palette (see the Custom Color example to override this).">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_basic_dense_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_basic_dense`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Basic Dense</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Instead of hand-building a color_map entry for every layer type, pick a named palette - it&#x27;s used as the fallback fill color for any layer type not given an explicit color_map override. A handful of the built-in palettes are shown below; see visualtorch.PALETTES.keys() for the full list.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_color_palettes_graph_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_color_palettes_graph`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Color Palettes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom color. The synthetic input node can be recolored too, keyed by visualtorch.Input in color_map just like any real layer type.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_custom_node_color_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_custom_node_color`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Color</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom node size">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_custom_node_size_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_custom_node_size`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Node Size</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Change the color transparency">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_custom_opacity_graph_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_custom_opacity_graph`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Opacity</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom spacing between layers">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_custom_spacing_layers_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_custom_spacing_layers`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Spacing for Layers</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="background_fill isn&#x27;t limited to plain white - it also accepts a transparent color (e.g. (0, 0, 0, 0)), useful for dropping a figure onto a paper/slide without a white box around it, or an opaque dark color for a nicer look on dark-mode pages.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_dark_background_graph_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_dark_background_graph`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dark Background</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, graph_view draws a fully-connected mesh between every pair of adjacent layers&#x27; neuron circles. That&#x27;s accurate for a genuinely dense layer (e.g. Linear), but misleading for a convolutional one - a Conv2d&#x27;s real connectivity is local and shared across spatial positions, not &quot;every input channel wired to every output channel.&quot; Setting show_neurons=False draws each layer as a single box instead, which is the more honest representation for a conv-heavy model.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_residual_block_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_residual_block`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Hiding Individual Neurons</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="By default, graph_view&#x27;s node/box size is fairly small - fine for a quick look, but often too small once you want a crisp, presentation- or paper-quality image. The main lever is node_size (in pixels, applies whether you&#x27;re using show_neurons=True circles or show_neurons=False boxes), paired with layer_spacing/``node_spacing`` so a bigger node size still has enough room around it. See also the Custom Node Size example for a more focused look at node_size alone.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_higher_resolution_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_higher_resolution`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Higher Resolution</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of an Inception-style block: four parallel branches (a plain Conv2d+BatchNorm2d, a 1x1-then-3x3 conv, a 1x1-then-5x5 conv, and a max-pool-then-1x1-conv) that all read the same input and merge into a shared projection layer.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_inception_block_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_inception_block`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Branch Merge (Inception-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of a model whose forward() takes two separate input tensors instead of one - an image branch (Conv2d + global pooling) and a tabular-vector branch (a small MLP) - merged by concatenation before a shared head. This is the pattern used by siamese networks and multi-modal architectures.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_multi_input_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_multi_input`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Input Model (Siamese-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A leaf layer&#x27;s forward() doesn&#x27;t always return a single tensor - nn.LSTM returns (output, (h_n, c_n)): the full sequence of hidden states, plus the final hidden and cell states. With show_dimension=True, every one of those output tensors&#x27; shapes is printed, not just the first, so a downstream layer that consumes h_n instead of output (as this model does) doesn&#x27;t leave its actual input shape unaccounted for.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_multi_output_shapes_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_multi_output_shapes`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Output Layer Shapes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A real, torchvision-provided architecture (not a toy model) - resnet18 has 8 residual blocks across 4 stages, with a projection shortcut (an extra Conv2d+BatchNorm2d in the skip path) at the first block of each of the last 3 stages, where the spatial size is downsampled and the channel count changes. Each residual skip connection is correctly routed above the diagram.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_resnet18_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_resnet18`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ResNet-18</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A small U-Net: two downsampling encoder stages, a bottleneck, and two upsampling decoder stages, with a skip connection concatenating each encoder stage&#x27;s output into its corresponding decoder stage. Both skip connections are genuine bypasses (around the pooling/bottleneck path) and are correctly routed above the diagram, nested since the two spans overlap.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_unet_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_unet`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">U-Net</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A small Vision Transformer: a Conv2d patch-embedding (splitting the image into non-overlapping patches and projecting each to a vector), a learned positional embedding added on, and a Transformer encoder over the resulting patch sequence.">

.. only:: html

  .. image:: /usage_examples/graph/images/thumb/sphx_glr_plot_vit_thumb.png
    :alt:

  :doc:`/usage_examples/graph/plot_vit`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vision Transformer (ViT)</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>

============
LeNet Style
============

These examples cover LeNet style visualization


.. raw:: html

  <div id='sg-tag-list' class='sphx-glr-tag-list'></div>


.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of basic custom model">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_basic_custom_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_basic_custom_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Basic Custom</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Instead of hand-building a color_map entry for every layer type, pick a named palette - it&#x27;s used as the fallback fill color for any layer type not given an explicit color_map override. A handful of the built-in palettes are shown below; see visualtorch.PALETTES.keys() for the full list.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_color_palettes_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_color_palettes_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Color Palettes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom color. The synthetic input box can be recolored too, keyed by visualtorch.Input in color_map just like any real layer type - left uncustomized, it would default to the same color as Conv2d here, since both would otherwise claim the same slot in the color wheel.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_custom_color_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_custom_color_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Color</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Change the color transparency">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_custom_opacity_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_custom_opacity_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Opacity</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom orientation for layers without real spatial/channel structure (a 1D shape, or a 2D shape like an RNN/attention layer&#x27;s (seq_len, hidden_size)).">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_custom_orientation_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_custom_orientation_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Orientation</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom shading">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_custom_shading_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_custom_shading_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Shading</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of custom spacing">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_custom_spacing_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_custom_spacing_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Custom Spacing</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="background_fill isn&#x27;t limited to plain white - it also accepts a transparent color (e.g. (0, 0, 0, 0)), useful for dropping a figure onto a paper/slide without a white box around it, or an opaque dark color for a nicer look on dark-mode pages.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_dark_background_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_dark_background_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Dark Background</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="lenet_view&#x27;s box size is mainly controlled by scale_xy (each stacked plane&#x27;s spatial width/height). Unlike flow_view, its scale_z already defaults to 1 rather than 0.1, so the per-slice depth is rarely the bottleneck here - scale_xy is the lever that actually makes each plane bigger and easier to read. scale_z is instead capped by max_channels (default 100): a layer with more channels than that gets its slice count clamped, not scaled further.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_higher_resolution_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_higher_resolution_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Higher Resolution</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualize some layers only. type_ignore hides layer types you don&#x27;t care about (here, ReLU and Flatten); show_input=False is the same idea applied to the synthetic input box itself - both trim the diagram down to just the layers worth looking at.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_ignore_layers_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_ignore_layers_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Ignore Layers</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of basic sequential model. No color_map is passed here, so each layer type is assigned a color automatically from a colorblind-safe default palette (see the Custom Color example to override this).">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_basic_sequential_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_basic_sequential_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">LeNet Style Basic Sequential</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same Inception-style block as the graph style&#x27;s multi-branch example - four parallel branches (a plain Conv2d+BatchNorm2d, a 1x1-then-3x3 conv, a 1x1-then-5x5 conv, and a max-pool-then-1x1-conv) that all read the same input and merge into a shared projection layer - rendered in lenet style instead.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_inception_block_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_inception_block_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Branch Merge (Inception-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same two-branch model as the graph style&#x27;s multi-input example - an image branch (Conv2d + global pooling) and a tabular-vector branch (a small MLP) - merged by concatenation before a shared head, rendered in lenet style instead.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_multi_input_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_multi_input_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Input Model (Siamese-style)</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="A leaf layer&#x27;s forward() doesn&#x27;t always return a single tensor - nn.LSTM returns (output, (h_n, c_n)): the full sequence of hidden states, plus the final hidden and cell states. show_dimension defaults to True for this style, and every one of those output tensors&#x27; shapes is printed, not just the first, so a downstream layer that consumes h_n instead of output (as this model does) doesn&#x27;t leave its actual input shape unaccounted for.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_multi_output_shapes_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_multi_output_shapes_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multi-Output Layer Shapes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same real, torchvision-provided resnet18 architecture as the graph/``flow`` styles&#x27; examples - 8 residual blocks across 4 stages, with a projection shortcut where channels/spatial size change - rendered in lenet style instead.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_resnet18_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_resnet18_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">ResNet-18</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualization of a classic ResNet-style residual block: Conv2d + BatchNorm2d, twice, with a plain identity shortcut around them and a final ReLU.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_residual_block_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_residual_block_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Residual Block</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same small U-Net as the graph/``flow`` styles&#x27; examples, rendered in lenet style instead - the contracting-then-expanding channel/spatial shape naturally produces the classic U-Net silhouette.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_unet_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_unet_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">U-Net</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The same small Vision Transformer as the graph/``flow`` styles&#x27; ViT examples, rendered in lenet style instead. A Transformer layer&#x27;s (seq_len, hidden_size) shape has no real spatial/channel structure, so hidden_size (the feature/channel-like dimension) drives the stacked-plane depth the same way a CNN&#x27;s channel count does, keeping every layer&#x27;s look consistent throughout the diagram.">

.. only:: html

  .. image:: /usage_examples/lenet_style/images/thumb/sphx_glr_plot_vit_lenet_style_thumb.png
    :alt:

  :doc:`/usage_examples/lenet_style/plot_vit_lenet_style`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Vision Transformer (ViT)</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /usage_examples/flow/index.rst
   /usage_examples/graph/index.rst
   /usage_examples/lenet_style/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: usage_examples_python.zip </usage_examples/usage_examples_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: usage_examples_jupyter.zip </usage_examples/usage_examples_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
