Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub
(pytorchbook) C:\> conda install pytorch torchvision cpuonly\-c pytorchInstalling CUDACUDA: Installing drivers for a GeForce graphics card, NVIDIA’s cuDNN, andCUDA Toolkit can be challenging and is highly dependent on which modelyou own and which OS you use.For installing GeForce’s drivers, go to GeForce’s website(https://www.geforce.com/drivers), select your OS and the model of yourgraphics card, and follow the installation instructions.For installing NVIDIA’s CUDA Deep Neural Network library (cuDNN), youneed to register at https://developer.nvidia.com/cudnn.For installing CUDA Toolkit (https://developer.nvidia.com/cuda-toolkit), pleasefollow instructions for your OS and choose a local installer or executable file.macOS: If you’re a macOS user, please beware that PyTorch’s binaries DONOT support CUDA, meaning you’ll need to install PyTorch from source ifyou want to use your GPU. This is a somewhat complicated process (asdescribed in https://github.com/pytorch/pytorch#from-source), so, if you don’tfeel like doing it, you can choose to proceed without CUDA, and you’ll still beable to execute the code in this book promptly.4. TensorBoardTensorBoard is TensorFlow’s visualization toolkit, and "provides the visualizationand tooling needed for machine learning experimentation." [24]TensorBoard is a powerful tool, and we can use it even if we are developing modelsin PyTorch. Luckily, you don’t need to install the whole TensorFlow to get it; youcan easily install TensorBoard alone using Conda. You just need to run thiscommand in your terminal or Anaconda prompt (again, after activating theenvironment):(pytorchbook)$ conda install -c conda-forge tensorboardEnvironment | 15
5. GraphViz and Torchviz (optional)This step is optional, mostly because the installation of GraphVizcan sometimes be challenging (especially on Windows). If for anyreason you do not succeed in installing it correctly, or if youdecide to skip this installation step, you will still be able toexecute the code in this book (except for a couple of cells thatgenerate images of a model’s structure in the "DynamicComputation Graph" section of Chapter 1).GraphViz is an open source graph visualization software. It is "a way of representingstructural information as diagrams of abstract graphs and networks." [25]We need to install GraphViz to use TorchViz, a neat package that allows us tovisualize a model’s structure. Please check the installation instructions for your OSat https://www.graphviz.org/download/.If you are using Windows, please use the GraphViz’s WindowsPackage installer at https://graphviz.gitlab.io/_pages/Download/windows/graphviz-2.38.msi.You also need to add GraphViz to the PATH (environmentvariable) in Windows. Most likely, you can find the GraphVizexecutable file at C:\ProgramFiles(x86)\Graphviz2.38\bin.Once you find 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 Addto Windows PATH Environment Variable." [26]For additional information, you can also check the "How to Install GraphvizSoftware" [27] guide.After installing GraphViz, you can install the torchviz [28] package. This package isnot part of Anaconda Distribution Repository [29] and is only available at PyPI [30] , thePython Package Index, so we need to pip install it.Once again, open a terminal or Anaconda prompt and run this command (just oncemore: after activating the environment):16 | Setup Guide
- Page 2 and 3: Deep Learning with PyTorchStep-by-S
- Page 4 and 5: "What I cannot create, I do not und
- Page 6 and 7: Train-Validation-Test Split. . . .
- Page 8 and 9: Random Split. . . . . . . . . . . .
- Page 10 and 11: The Precision Quirk . . . . . . . .
- Page 12 and 13: A REAL Filter . . . . . . . . . . .
- Page 14 and 15: Jupyter Notebook . . . . . . . . .
- Page 16 and 17: Stacked RNN . . . . . . . . . . . .
- Page 18 and 19: Attention Mechanism . . . . . . . .
- Page 20 and 21: 4. Positional Encoding. . . . . . .
- Page 22 and 23: Model Configuration & Training . .
- Page 24 and 25: AcknowledgementsFirst and foremost,
- Page 26 and 27: Frequently Asked Questions (FAQ)Why
- Page 28 and 29: There is yet another advantage of f
- Page 30 and 31: • Classes and methods are written
- Page 32 and 33: What’s Next?It’s time to set up
- Page 34 and 35: After choosing a repository, it wil
- Page 36 and 37: 1. AnacondaIf you don’t have Anac
- Page 38 and 39: 3. PyTorchPyTorch is the coolest de
- Page 42 and 43: (pytorchbook)$ pip install torchviz
- Page 44 and 45: 7. JupyterAfter cloning the reposit
- Page 46 and 47: Part IFundamentals| 21
- Page 48 and 49: notebook. If not, just click on Cha
- Page 50 and 51: Also, let’s say that, on average,
- Page 52 and 53: There is one exception to the "alwa
- Page 54 and 55: Random Initialization1 # Step 0 - I
- Page 56 and 57: Batch, Mini-batch, and Stochastic G
- Page 58 and 59: Outputarray([[-2. , -1.94, -1.88, .
- Page 60 and 61: one matrix for each data point, eac
- Page 62 and 63: Sure, different values of b produce
- Page 64 and 65: Output-3.044811379650508 -1.8337537
- Page 66 and 67: each parameter using the chain rule
- Page 68 and 69: What’s the impact of one update o
- Page 70 and 71: gradients, we know we need to take
- Page 72 and 73: Very High Learning RateWait, it may
- Page 74 and 75: true_b = 1true_w = 2N = 100# Data G
- Page 76 and 77: Let’s look at the cross-sections
- Page 78 and 79: Zero Mean and Unit Standard Deviati
- Page 80 and 81: Sure, in the real world, you’ll n
- Page 82 and 83: computing the loss, as shown in the
- Page 84 and 85: • visualizing the effects of usin
- Page 86 and 87: If you’re using Jupyter’s defau
- Page 88 and 89: Notebook Cell 1.1 - Splitting synth
5. GraphViz and Torchviz (optional)
This step is optional, mostly because the installation of GraphViz
can sometimes be challenging (especially on Windows). If for any
reason you do not succeed in installing it correctly, or if you
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).
GraphViz is an open source graph visualization software. It is "a way of representing
structural information as diagrams of abstract graphs and networks." [25]
We need to install GraphViz to use TorchViz, a neat package that allows us to
visualize a model’s structure. Please check the installation instructions for your OS
at https://www.graphviz.org/download/.
If you are using Windows, please use the GraphViz’s Windows
Package installer at 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 the GraphViz
executable file at C:\ProgramFiles(x86)\Graphviz2.38\bin.
Once you find 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." [26]
For additional information, you can also check the "How to Install Graphviz
Software" [27] guide.
After installing GraphViz, you can install the torchviz [28] package. This package is
not part of Anaconda Distribution Repository [29] and is only available at PyPI [30] , the
Python Package Index, so we need to pip install it.
Once again, open a terminal or Anaconda prompt and run this command (just once
more: after activating the environment):
16 | Setup Guide