
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "usage_examples/layered/plot_basic_sequential.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_layered_plot_basic_sequential.py>`
        to download the full example code.

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

.. _sphx_glr_usage_examples_layered_plot_basic_sequential.py:

Basic Sequential
=======================================

Visualization of basic sequential model

.. GENERATED FROM PYTHON SOURCE LINES 6-36



.. image-sg:: /usage_examples/layered/images/sphx_glr_plot_basic_sequential_001.png
   :alt: plot basic sequential
   :srcset: /usage_examples/layered/images/sphx_glr_plot_basic_sequential_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


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

    # Example of a simple CNN model using nn.Sequential
    model = nn.Sequential(
        nn.Conv2d(3, 16, kernel_size=3, padding=1),
        nn.ReLU(),
        nn.MaxPool2d(2, 2),
        nn.Conv2d(16, 32, kernel_size=3, padding=1),
        nn.ReLU(),
        nn.MaxPool2d(2, 2),
        nn.Conv2d(32, 64, kernel_size=3, padding=1),
        nn.ReLU(),
        nn.MaxPool2d(2, 2),
        nn.Flatten(),
        nn.Linear(64 * 28 * 28, 256),  # Adjusted the input size for the Linear layer
        nn.ReLU(),
        nn.Linear(256, 10),  # Assuming 10 output classes
    )

    input_shape = (1, 3, 224, 224)

    img = visualtorch.layered_view(model, input_shape=input_shape, legend=True)

    plt.axis("off")
    plt.tight_layout()
    plt.imshow(img)
    plt.show()


.. _sphx_glr_download_usage_examples_layered_plot_basic_sequential.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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