Skip to content

Commit

Permalink
Merge branch 'main' into add-redirect-dist-tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
svekars authored Nov 5, 2024
2 parents e61d5f6 + 5323ee2 commit b1f2b90
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 57 deletions.
1 change: 1 addition & 0 deletions .jenkins/validate_tutorials_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

NOT_RUN = [
"beginner_source/basics/intro", # no code
"beginner_source/introyt/introyt_index", # no code
"beginner_source/onnx/intro_onnx",
"beginner_source/profiler",
"beginner_source/saving_loading_models",
Expand Down
3 changes: 3 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ file:///f:/libtmp/some_file

#Ignore links with "file:///" to catch any other example links
file:\/\/\/.*

# Ignore colab link in the setting of conf.py
https://pytorch.org/tutorials/beginner/colab/n
18 changes: 18 additions & 0 deletions _static/css/custom2.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@
margin-bottom: 5px;
}
}

/* Left nav for 2nd level nav */

.pytorch-left-menu li.toctree-l2 {
padding-left: 10px;
}

.pytorch-left-menu li.toctree-l2.current > a, {
color: #ee4c2c;
}

.pytorch-left-menu li.toctree-l2.current a:link.reference.internal {
color: #ee4c2c;
}

.pytorch-left-menu li.toctree-l1.current > a:before {
content: "";
}
52 changes: 52 additions & 0 deletions _static/js/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
document.addEventListener("DOMContentLoaded", function() {
// Select all <li> elements with the class "toctree-l1"
var toctreeItems = document.querySelectorAll('li.toctree-l1');

toctreeItems.forEach(function(item) {
// Find the link within the item
var link = item.querySelector('a');
var nestedList = item.querySelector('ul');

if (link && nestedList) {
// Create a span element for the "[+]" or "[-]" sign
var expandSign = document.createElement('span');
expandSign.style.cursor = 'pointer'; // Make it look clickable

// Use the link text as a unique key for localStorage
var sectionKey = 'section_' + link.textContent.trim().replace(/\s+/g, '_');

// Retrieve the saved state from localStorage
var isExpanded = localStorage.getItem(sectionKey);

// If no state is saved, default to expanded for "Learn the Basics" and collapsed for others
if (isExpanded === null) {
isExpanded = (link.textContent.trim() === 'Learn the Basics') ? 'true' : 'false';
localStorage.setItem(sectionKey, isExpanded);
}

if (isExpanded === 'true') {
nestedList.style.display = 'block'; // Expand the section
expandSign.textContent = '[-] '; // Show "[-]" since it's expanded
} else {
nestedList.style.display = 'none'; // Collapse the section
expandSign.textContent = '[+] '; // Show "[+]" since it's collapsed
}

// Add a click event to toggle the nested list
expandSign.addEventListener('click', function() {
if (nestedList.style.display === 'none') {
nestedList.style.display = 'block';
expandSign.textContent = '[-] '; // Change to "[-]" when expanded
localStorage.setItem(sectionKey, 'true'); // Save state
} else {
nestedList.style.display = 'none';
expandSign.textContent = '[+] '; // Change back to "[+]" when collapsed
localStorage.setItem(sectionKey, 'false'); // Save state
}
});

// Insert the sign before the link
link.parentNode.insertBefore(expandSign, link);
}
});
});
19 changes: 19 additions & 0 deletions _templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{% extends "!layout.html" %}


<!-- Overrides needed for the multilevel nav -->
{% block menu %}
{% if 'singlehtml' not in builder %}
{% set global_toc = toctree(collapse=theme_collapse_navigation|tobool,
includehidden=theme_includehidden|tobool,
titles_only=True) %}
{% endif %}
{% if global_toc %}
{{ global_toc }}
{% else %}
<!-- Local TOC -->
<div class="local-toc">{{ toc }}</div>
{% endif %}
{% endblock %}
<!-- End of overrides needed for the multilevel nav -->


{%- block content %}
{{ super() }}
<script>
Expand Down Expand Up @@ -29,6 +47,7 @@
</div>
{% endblock %}


{% block footer %}
{{ super() }}
<script>
Expand Down
14 changes: 12 additions & 2 deletions beginner_source/basics/intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
===================
Authors:
`Suraj Subramanian <https://github.com/suraj813>`_,
`Suraj Subramanian <https://github.com/subramen>`_,
`Seth Juarez <https://github.com/sethjuarez/>`_,
`Cassie Breviu <https://github.com/cassieview/>`_,
`Cassie Breviu <https://github.com/cassiebreviu/>`_,
`Dmitry Soshnikov <https://soshnikov.com/>`_,
`Ari Bornstein <https://github.com/aribornstein/>`_
Expand Down Expand Up @@ -49,6 +49,16 @@
.. include:: /beginner_source/basics/qs_toc.txt
.. toctree::
:maxdepth: 2
:hidden:
quickstart_tutorial
tensorqs_tutorial
data_tutorial
transforms_tutorial
buildmodel_tutorial
autogradqs_tutorial
optimization_tutorial
saveloadrun_tutorial
"""
1 change: 1 addition & 0 deletions beginner_source/former_torchies_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PyTorch for Former Torch Users
This tutorial is out of date. Please check out the PyTorch tutorials here: https://pytorch.org/tutorials/

You will be redirected in 3 seconds.

.. raw:: html

<meta http-equiv="Refresh" content="3; url='https://pytorch.org/tutorials/'" />
27 changes: 4 additions & 23 deletions beginner_source/introyt.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
`Introduction <introyt/introyt1_tutorial.html>`_ ||
`Tensors <introyt/tensors_deeper_tutorial.html>`_ ||
`Autograd <introyt/autogradyt_tutorial.html>`_ ||
`Building Models <introyt/modelsyt_tutorial.html>`_ ||
`TensorBoard Support <introyt/tensorboardyt_tutorial.html>`_ ||
`Training Models <introyt/trainingyt.html>`_ ||
`Model Understanding <introyt/captumyt.html>`_

Introduction to PyTorch - YouTube Series
========================================

Authors:
`Brad Heintz <https://github.com/fbbradheintz>`_

This tutorial follows along with the `PyTorch Beginner Series <https://www.youtube.com/playlist?list=PL_lsbAsL_o2CTlGHgMxNrKhzP97BaG9ZN>`_ on YouTube.

`This tutorial assumes a basic familiarity with Python and Deep Learning concepts.`

Running the Tutorial Code
-------------------------
You can run this tutorial in a couple of ways:
This page has been moved.

- **In the cloud**: This is the easiest way to get started! Each section has a Colab link at the top, which opens a notebook with the code in a fully-hosted environment. Pro tip: Use Colab with a GPU runtime to speed up operations *Runtime > Change runtime type > GPU*
- **Locally**: This option requires you to setup PyTorch and torchvision first on your local machine (`installation instructions <https://pytorch.org/get-started/locally/>`_). Download the notebook or copy the code into your favorite IDE.
Redirecting now...

.. include:: /beginner_source/introyt/tocyt.txt
.. raw:: html

.. toctree::
:hidden:
<meta http-equiv="Refresh" content="0; url='https://pytorch.org/tutorials/beginner/introyt/introyt_index.html'" />
2 changes: 1 addition & 1 deletion beginner_source/introyt/README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Introduction to PyTorch on YouTube
----------------------------------

1. introyt.rst
1. introyt.py
Introduction to PyTorch - Youtube Series
https://pytorch.org/tutorials/beginner/introyt/introyt.html

Expand Down
38 changes: 38 additions & 0 deletions beginner_source/introyt/introyt_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
`Introduction <introyt/introyt1_tutorial.html>`_ ||
`Tensors <introyt/tensors_deeper_tutorial.html>`_ ||
`Autograd <introyt/autogradyt_tutorial.html>`_ ||
`Building Models <introyt/modelsyt_tutorial.html>`_ ||
`TensorBoard Support <introyt/tensorboardyt_tutorial.html>`_ ||
`Training Models <introyt/trainingyt.html>`_ ||
`Model Understanding <introyt/captumyt.html>`_
Introduction to PyTorch - YouTube Series
========================================
Authors:
`Brad Heintz <https://github.com/fbbradheintz>`_
This tutorial follows along with the `PyTorch Beginner Series <https://www.youtube.com/playlist?list=PL_lsbAsL_o2CTlGHgMxNrKhzP97BaG9ZN>`_ on YouTube.
`This tutorial assumes a basic familiarity with Python and Deep Learning concepts.`
Running the Tutorial Code
-------------------------
You can run this tutorial in a couple of ways:
- **On the cloud**: This is the easiest way to get started! Each section has a Colab link at the top, which opens a notebook with the code in a fully-hosted environment. Pro tip: Use Colab with a GPU runtime to speed up operations *Runtime > Change runtime type > GPU*
- **Locally**: This option requires you to set up PyTorch and torchvision on your local machine (`installation instructions <https://pytorch.org/get-started/locally/>`_). Download the notebook or copy the code into your favorite IDE.
.. toctree::
:maxdepth: 2
:hidden:
introyt1_tutorial
tensors_deeper_tutorial
autogradyt_tutorial
modelsyt_tutorial
tensorboardyt_tutorial
trainingyt
captumyt
"""
4 changes: 4 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def reset_seeds(gallery_conf, fname):
'css/custom2.css'
]

html_js_files = [
"js/custom.js",
]

def setup(app):
# NOTE: in Sphinx 1.8+ `html_css_files` is an official configuration value
# and can be moved outside of this function (and the setup(app) function
Expand Down
38 changes: 7 additions & 31 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Welcome to PyTorch Tutorials
:header: Introduction to PyTorch on YouTube
:card_description: An introduction to building a complete ML workflow with PyTorch. Follows the PyTorch Beginner Series on YouTube.
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
:link: beginner/introyt.html
:link: beginner/introyt/introyt_index.html
:tags: Getting-Started

.. customcarditem::
Expand Down Expand Up @@ -906,7 +906,7 @@ Additional Resources
.. Page TOC
.. -----------------------------------------
.. toctree::
:maxdepth: 2
:maxdepth: 1
:hidden:
:includehidden:
:caption: PyTorch Recipes
Expand All @@ -915,39 +915,15 @@ Additional Resources
See All Prototype Recipes <prototype/prototype_index>

.. toctree::
:maxdepth: 2
:hidden:
:includehidden:
:caption: Introduction to PyTorch

beginner/basics/intro
beginner/basics/quickstart_tutorial
beginner/basics/tensorqs_tutorial
beginner/basics/data_tutorial
beginner/basics/transforms_tutorial
beginner/basics/buildmodel_tutorial
beginner/basics/autogradqs_tutorial
beginner/basics/optimization_tutorial
beginner/basics/saveloadrun_tutorial
advanced/custom_ops_landing_page
beginner/introyt/introyt_index

.. toctree::
:maxdepth: 2
:hidden:
:includehidden:
:caption: Introduction to PyTorch on YouTube

beginner/introyt
beginner/introyt/introyt1_tutorial
beginner/introyt/tensors_deeper_tutorial
beginner/introyt/autogradyt_tutorial
beginner/introyt/modelsyt_tutorial
beginner/introyt/tensorboardyt_tutorial
beginner/introyt/trainingyt
beginner/introyt/captumyt

.. toctree::
:maxdepth: 2
:maxdepth: 1
:hidden:
:includehidden:
:caption: Learning PyTorch
Expand All @@ -960,7 +936,7 @@ Additional Resources
intermediate/pinmem_nonblock

.. toctree::
:maxdepth: 2
:maxdepth: 1
:includehidden:
:hidden:
:caption: Image and Video
Expand Down Expand Up @@ -991,7 +967,7 @@ Additional Resources
intermediate/forced_alignment_with_torchaudio_tutorial

.. toctree::
:maxdepth: 2
:maxdepth: 1
:includehidden:
:hidden:
:caption: Backends
Expand All @@ -1010,7 +986,7 @@ Additional Resources
advanced/pendulum

.. toctree::
:maxdepth: 2
:maxdepth: 1
:includehidden:
:hidden:
:caption: Deploying PyTorch Models in Production
Expand Down

0 comments on commit b1f2b90

Please sign in to comment.