
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "usage_examples/lenet_style/plot_outline_width_lenet_style.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_usage_examples_lenet_style_plot_outline_width_lenet_style.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_usage_examples_lenet_style_plot_outline_width_lenet_style.py:

Outline Width
=======================================
Visualization of thin vs thick outline border using the ``outline_width`` parameter
in the lenet style.

.. GENERATED FROM PYTHON SOURCE LINES 6-55



.. image-sg:: /usage_examples/lenet_style/images/sphx_glr_plot_outline_width_lenet_style_001.png
   :alt: outline_width=1 (default), outline_width=8 (thick)
   :srcset: /usage_examples/lenet_style/images/sphx_glr_plot_outline_width_lenet_style_001.png
   :class: sphx-glr-single-img





.. code-block:: Python

    import matplotlib.pyplot as plt
    import torch
    import torch.nn.functional as func
    import visualtorch
    from torch import nn


    class SimpleCNN(nn.Module):
        """Simple CNN Model."""

        def __init__(self) -> None:
            super().__init__()
            self.conv1 = nn.Conv2d(3, 16, kernel_size=3, padding=1)
            self.conv2 = nn.Conv2d(16, 32, kernel_size=3, padding=1)
            self.fc1 = nn.Linear(32 * 56 * 56, 128)
            self.fc2 = nn.Linear(128, 10)

        def forward(self, x: torch.Tensor) -> torch.Tensor:
            """Define the forward pass."""
            x = self.conv1(x)
            x = func.relu(x)
            x = func.max_pool2d(x, 2, 2)
            x = self.conv2(x)
            x = func.relu(x)
            x = func.max_pool2d(x, 2, 2)
            x = x.view(x.size(0), -1)
            x = self.fc1(x)
            x = func.relu(x)
            return self.fc2(x)


    model = SimpleCNN()
    input_shape = (1, 3, 224, 224)


    fig, axes = plt.subplots(1, 2, figsize=(12, 4))

    img_thin = visualtorch.render(model, input_shape=input_shape, style="lenet", outline_width=1)
    axes[0].imshow(img_thin)
    axes[0].axis("off")
    axes[0].set_title("outline_width=1 (default)")

    img_thick = visualtorch.render(model, input_shape=input_shape, style="lenet", outline_width=8)
    axes[1].imshow(img_thick)
    axes[1].axis("off")
    axes[1].set_title("outline_width=8 (thick)")

    plt.tight_layout()
    plt.show()


.. _sphx_glr_download_usage_examples_lenet_style_plot_outline_width_lenet_style.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

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

      :download:`Download Jupyter notebook: plot_outline_width_lenet_style.ipynb <plot_outline_width_lenet_style.ipynb>`

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

      :download:`Download Python source code: plot_outline_width_lenet_style.py <plot_outline_width_lenet_style.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_outline_width_lenet_style.zip <plot_outline_width_lenet_style.zip>`


.. only:: html

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

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