

.. _sphx_glr_usage_examples_flow:

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


.. toctree::
   :hidden:

   /usage_examples/flow/plot_2d_view
   /usage_examples/flow/plot_basic_custom
   /usage_examples/flow/plot_basic_sequential
   /usage_examples/flow/plot_color_palettes_flow
   /usage_examples/flow/plot_custom_color
   /usage_examples/flow/plot_custom_opacity
   /usage_examples/flow/plot_custom_orientation
   /usage_examples/flow/plot_custom_shading
   /usage_examples/flow/plot_custom_spacing
   /usage_examples/flow/plot_dark_background
   /usage_examples/flow/plot_higher_resolution_flow
   /usage_examples/flow/plot_ignore_layers
   /usage_examples/flow/plot_inception_block_flow
   /usage_examples/flow/plot_multi_input_flow
   /usage_examples/flow/plot_multi_output_shapes_flow
   /usage_examples/flow/plot_resnet18_flow
   /usage_examples/flow/plot_residual_block_flow
   /usage_examples/flow/plot_unet_flow
   /usage_examples/flow/plot_vit_flow

