

.. _sphx_glr_usage_examples_lenet_style:

============
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:

   /usage_examples/lenet_style/plot_basic_custom_lenet_style
   /usage_examples/lenet_style/plot_color_palettes_lenet_style
   /usage_examples/lenet_style/plot_custom_color_lenet_style
   /usage_examples/lenet_style/plot_custom_opacity_lenet_style
   /usage_examples/lenet_style/plot_custom_orientation_lenet_style
   /usage_examples/lenet_style/plot_custom_shading_lenet_style
   /usage_examples/lenet_style/plot_custom_spacing_lenet_style
   /usage_examples/lenet_style/plot_dark_background_lenet_style
   /usage_examples/lenet_style/plot_higher_resolution_lenet_style
   /usage_examples/lenet_style/plot_ignore_layers_lenet_style
   /usage_examples/lenet_style/plot_basic_sequential_lenet_style
   /usage_examples/lenet_style/plot_inception_block_lenet_style
   /usage_examples/lenet_style/plot_multi_input_lenet_style
   /usage_examples/lenet_style/plot_multi_output_shapes_lenet_style
   /usage_examples/lenet_style/plot_resnet18_lenet_style
   /usage_examples/lenet_style/plot_residual_block_lenet_style
   /usage_examples/lenet_style/plot_unet_lenet_style
   /usage_examples/lenet_style/plot_vit_lenet_style

