: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="Visualization of custom color">

.. 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 1 dim layers">

.. 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="Visualize some layers only">

.. 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="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>


.. 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="Visualization of custom color. The synthetic input node can be recolored too, keyed by visualtorch.InputDummyLayer 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="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="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="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>


.. 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. 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="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>


.. 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>`_
