{"id":13449870,"url":"https://github.com/dvgodoy/PyTorchStepByStep","last_synced_at":"2025-03-22T23:31:52.952Z","repository":{"id":37388603,"uuid":"255638464","full_name":"dvgodoy/PyTorchStepByStep","owner":"dvgodoy","description":"Official repository of my book: \"Deep Learning with PyTorch Step-by-Step: A Beginner's Guide\"","archived":false,"fork":false,"pushed_at":"2025-03-06T09:31:05.000Z","size":34873,"stargazers_count":1013,"open_issues_count":15,"forks_count":396,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-16T07:02:36.475Z","etag":null,"topics":["cnn-pytorch","deep-learning","python","pytorch","pytorch-tutorial","rnn-pytorch"],"latest_commit_sha":null,"homepage":"https://pytorchstepbystep.com","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvgodoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-14T14:51:41.000Z","updated_at":"2025-03-14T15:00:39.000Z","dependencies_parsed_at":"2024-04-14T10:24:43.197Z","dependency_job_id":"637c64b3-1de8-4ce1-9ba8-ef509c6e4b44","html_url":"https://github.com/dvgodoy/PyTorchStepByStep","commit_stats":{"total_commits":140,"total_committers":4,"mean_commits":35.0,"dds":"0.042857142857142816","last_synced_commit":"af568498ab364c5b96664ff36d527c3e8ecd2124"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvgodoy%2FPyTorchStepByStep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvgodoy%2FPyTorchStepByStep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvgodoy%2FPyTorchStepByStep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvgodoy%2FPyTorchStepByStep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvgodoy","download_url":"https://codeload.github.com/dvgodoy/PyTorchStepByStep/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245036111,"owners_count":20550661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnn-pytorch","deep-learning","python","pytorch","pytorch-tutorial","rnn-pytorch"],"created_at":"2024-07-31T06:01:00.354Z","updated_at":"2025-03-22T23:31:52.925Z","avatar_url":"https://github.com/dvgodoy.png","language":"Jupyter Notebook","readme":"# Deep Learning with PyTorch Step-by-Step\n\n## New book: \"A Hands-On Guide to Fine-Tuning LLMs\"\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/dvgodoy/FineTuningLLMs/blob/main/images/cover.png?raw=True\" width=\"200\"/\u003e\n  \u003cbr\u003e\n  \u003cstrong\u003e\u003ca href=\"https://www.amazon.com/dp/B0DV3Y1GMP\"\u003eKindle\u003c/a\u003e | \u003ca href=\"https://www.amazon.com/dp/B0DV4H7YW2\"\u003ePaperback\u003c/a\u003e | \u003ca href=\"https://leanpub.com/finetuning\"\u003ePDF [Leanpub]\u003ca\u003e | \u003ca href=\"https://danielgodoy.gumroad.com/l/finetuning\"\u003ePDF [Gumroad]\u003ca\u003e\u003c/strong\u003e\n\u003c/p\u003e\n\n## Revised for PyTorch 2.x!\nThe revised version addresses changes in PyTorch, Torchvision, HuggingFace, and other libraries. The chapters most affected were Chapter 4 (in Volume II) and Chapter 11 (in Volume III).\n\nPlease check the PDFs below containing the changes (check the paragraphs highlighted in red):\n- [Changes to Volume I](https://raw.githubusercontent.com/dvgodoy/PyTorchStepByStep/master/revision/v1.2/Revision_Volume1_v1.2.pdf)\n- [Changes to Volume II](https://raw.githubusercontent.com/dvgodoy/PyTorchStepByStep/master/revision/v1.2/Revision_Volume2_v1.2.pdf)\n- [Changes to Volume III](https://raw.githubusercontent.com/dvgodoy/PyTorchStepByStep/master/revision/v1.2/Revision_Volume3_v1.2.pdf)\n\n[![](images/new_books.png)](https://pytorchstepbystep.com)\n\nThis is the official repository of my book \"**Deep Learning with PyTorch Step-by-Step**\". Here you will find **one Jupyter notebook** for every **chapter** in the book.\n\nEach notebook contains **all the code shown** in its corresponding chapter, and you should be able to\n**run its cells in sequence** to get the **same outputs as shown in the book**. I strongly believe that being able to **reproduce the results** brings **confidence** to the reader.\n\nThere are **three** options for you to run the Jupyter notebooks:\n\n### Google Colab\n\nYou can easily **load the notebooks directly from GitHub** using Colab and run them using a **GPU** provided by Google. You need to be logged in a Google Account of your own.\n\nYou can go through the chapters already using the links below:\n\n#### Part I - Fundamentals\n\n- [Chapter 0 - Visualizing Gradient Descent](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter00.ipynb)\n- [Chapter 1 - A Simple Regression Problem](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter01.ipynb)\n- [Chapter 2 - Rethinking the Training Loop](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter02.ipynb)\n- [Chapter 2.1 - Going Classy](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter02.1.ipynb)\n- [Chapter 3 - A Simple Classification Problem](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter03.ipynb)\n\n#### Part II - Computer Vision\n\n- [Chapter 4 - Classifying Images](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter04.ipynb)\n- [Chapter 5 - Convolutions](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter05.ipynb)\n- [Chapter 6 - Rock, Paper, Scissors](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter06.ipynb)\n- [Chapter 7 - Transfer Learning](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter07.ipynb)\n- [Extra Chapter - Vanishing and Exploding Gradients](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/ChapterExtra.ipynb)\n\n#### Part III - Sequences\n\n- [Chapter 8 - Sequences](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter08.ipynb)\n- [Chapter 9 - Sequence-to-Sequence](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter09.ipynb)\n- [Chapter 10 - Transform and Roll Out](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter10.ipynb)\n\n#### Part IV - Natural Language Processing\n\n- [Chapter 11 - Down the Yellow Brick Rabbit Hole](https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter11.ipynb)\n\n### Binder\n\nYou can also **load the notebooks directly from GitHub** using Binder, but the process is slightly different. It will create an environment on the cloud and allow you to access **Jupyter's Home Page** in your browser, listing all available notebooks, just like in your own computer.\n\nIf you **make changes** to the notebooks, **make sure to download** them, since Binder **does not keep the changes** once you close it.\n\nYou can start your environment on the cloud right now using the button below:\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/dvgodoy/PyTorchStepByStep/master)\n\n### Local Installation\n\nThis option will give you more **flexibility**, but it will require **more effort to set up**. I encourage you to try setting up your own environment. It may seem daunting at first, but you can surely accomplish it following **seven easy steps**:\n\n**1 - Anaconda**\n\nIf you don’t have [**Anaconda’s Individual Edition**](https://www.anaconda.com/products/individual) installed yet, that would be a good time to do it - it is a very handy way to start - since it contains most of the Python libraries a data scientist will ever need to develop and train models. \n\nPlease follow **the installation instructions** for your OS:\n\n- [Windows](https://docs.anaconda.com/anaconda/install/windows/)\n- [macOS](https://docs.anaconda.com/anaconda/install/mac-os/)\n- [Linux](https://docs.anaconda.com/anaconda/install/linux/)\n\nMake sure you choose **Python 3.X** version since Python 2 was discontinued in January 2020.\n\n**2 - Conda (Virtual) Environments**\n\nVirtual environments are a convenient way to isolate Python installations associated with different projects.\n\nFirst, you need to choose a **name** for your environment :-) Let’s call ours `pytorchbook` (or anything else you find easier to remember). Then, you need to open a **terminal** (in Ubuntu) or **Anaconda Prompt** (in Windows or macOS) and type the following command:\n\n`conda create -n pytorchbook anaconda`\n\nThe command above creates a conda environment named `pytorchbook` and includes **all anaconda packages** in it (time to get a coffee, it will take a while...). If you want to learn more about creating and using conda environments, please check Anaconda’s [**Managing Environments**](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) user guide.\n\nDid it finish creating the environment? Good! It is time to **activate it**, meaning, making that Python installation the one to be used now. In the same terminal (or Anaconda Prompt), just type:\n\n`conda activate pytorchbook`\n\nYour prompt should look like this (if you’re using Linux)...\n\n`(pytorchbook)$`\n\nor like this (if you’re using Windows):\n\n`(pytorchbook)C:\\\u003e`\n\nDone! You are using a **brand new conda environment** now. You’ll need to **activate it** every time you open a new terminal or, if you’re a Windows or macOS user, you can open the corresponding Anaconda Prompt (it will show up as **Anaconda Prompt (pytorchbook)**, in our case), which will have it activated from start.\n\n**IMPORTANT**: From now on, I am assuming you’ll activate the `pytorchbook` environment every time you open a terminal / Anaconda Prompt. Further installation steps **must** be executed inside the environment.\n\n**3 - PyTorch**\n\nIt is time to install the star of the show :-) We can go straight to the [**Start Locally**](https://pytorch.org/get-started/locally/) section of its website and it will automatically select the options that best suit your local environment and it will show you the command to run.\n\nYour choices should look like:\n\n- PyTorch Build: \"Stable\"\n- Your OS: your operating system\n- Package: \"Conda\"\n- Language: \"Python\"\n- CUDA: \"None\" if you **don't** have a **GPU**, or the latest version (e.g. \"10.1\"), if you **have** a **GPU**.\n\nThe installation command will be shown right below your choices, so you can copy it. If you have a **Windows** computer and **no GPU**, you'd have to run the following command in your **Anaconda Prompt (pytorchbook)**:\n\n`(pytorchbook) C:\\\u003e conda install pytorch torchvision cpuonly -c pytorch`\n\n**4 - TensorBoard**\n\nTensorBoard is a powerful tool and we can use it even if we are developing models in PyTorch. Luckily, you don’t need to install the whole TensorFlow to get it, you can easily **install TensorBoard alone** using **conda**. You just need to run this command in your **terminal** or **Anaconda Prompt** (again, after activating the environment):\n\n`(pytorchbook)C:\\\u003e conda install -c conda-forge tensorboard`\n\n**5 - GraphViz and TorchViz (optional)**\n\n\u003e This step is optional, mostly because the installation of GraphViz can be challenging sometimes (especially on Windows). If, for any reason, you do not succeed in installing it correctly, or if you\n\u003e decide to skip this installation step, you will still be **able to execute the code in this book** (except for a couple of cells that generate images of a model’s structure in the Dynamic Computation Graph section of Chapter 1).\n\nWe need to install GraphViz to be able to use **TorchViz**, a neat package that allows us to visualize a  model’s structure. Please check the [**installation instructions**]( https://www.graphviz.org/download/) for your OS. \n\n\u003e If you are using **Windows**, please use the installer at [GraphViz's Windows Package](https://graphviz.gitlab.io/_pages/Download/windows/graphviz-2.38.msi). You also need to  add GraphViz to the PATH (environment variable) in Windows. Most likely, you can find GraphViz executable file at `C:\\ProgramFiles(x86)\\Graphviz2.38\\bin`. Once you found it, you need to set or change the PATH accordingly, adding GraphViz's location to it. For more details on how to do that, please refer to [How to Add to Windows PATH Environment Variable](https://bit.ly/3fIwYA5).\n\nFor additional information, you can also check the [How to Install Graphviz Software](https://bit.ly/30Ayct3) guide. \n\nIf you installed GraphViz successfully, you can install the [torchviz](https://github.com/szagoruyko/pytorchviz) package. This package is not part of Anaconda Distribution Repository and is only available at PyPI , the Python Package Index, so we need to pip install it.\n\nOnce again, open a **terminal** or **Anaconda Prompt** and run this command (just once\nmore: after activating the environment):\n\n`(pytorchbook)C:\\\u003e pip install torchviz`\n\n**6 - Git**\n\nIt is way beyond the scope of this guide to introduce you to version control and its most popular tool: `git`. If you are familiar with it already, great, you can skip this section altogether!\n\nOtherwise, I’d recommend you to learn more about it, it will **definitely** be useful for you later down the line. In the meantime, I will show you the bare minimum, so you can use `git` to **clone this repository** containing all code used in this book - so you have your own, local copy of it and can modify and experiment with it as you please.\n\nFirst, you need to install it. So, head to its [downloads](https://git-scm.com/downloads) page and follow instructions for your OS. Once installation is complete, please open a **new terminal** or **Anaconda Prompt** (it's OK to close the previous one). In the new terminal or Anaconda Prompt, you should be able to **run `git` commands**. To clone this repository, you only need to run:\n\n`(pytorchbook)C:\\\u003e git clone https://github.com/dvgodoy/PyTorchStepByStep.git`\n\nThe command above will create a `PyTorchStepByStep` folder which contains a **local copy** of everything available on this GitHub’s repository.\n\n**7 - Jupyter**\n\nAfter cloning the repository, navigate to the `PyTorchStepByStep` and, **once inside it**, you only need to **start Jupyter** on your terminal or Anaconda Prompt:\n\n`(pytorchbook)C:\\\u003e jupyter notebook`\n\nThis will open your browser up and you will see **Jupyter's Home Page** containing this repository's notebooks and code.\n\nCongratulations! You are ready to go through the chapters' notebooks!\n\n","funding_links":[],"categories":["Transformers ##"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvgodoy%2FPyTorchStepByStep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvgodoy%2FPyTorchStepByStep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvgodoy%2FPyTorchStepByStep/lists"}