Source: Deep Learning on Medium
Deep Learning w/ PyTorch on Your Desktop/Laptop/Server
What is PyTorch and How is it different from Tensorflow?
Tensorflow is based on Theano and has been developed by Google, whereas PyTorch is based on Torch and has been developed by Facebook.
The most important difference between the two is the way these frameworks define the computational graphs. While Tensorflow creates a static graph, PyTorch believes in a dynamic graph. So what does this mean? In Tensorflow, you first have to define the entire computation graph of the model and then run your ML model. But in PyTorch, you can define/manipulate your graph on-the-go. This is particularly helpful while using variable length inputs in RNNs.
Thats the biggest reason everyone uses PyTorch for some types of problems. It can be dynamically constructed and executed. So assuming we are building real world systems we would also need to do that. Hence this article.
Lets Get Started…
Please download and install Conda from here (choose depending on your platform) https://www.anaconda.com/distribution/
Download the Files for this article here … http://bit.ly/2n6Y8L5
Pytorch comes in Two Flavours, first which executes on CPU and the second which executes on (Nvidia) GPUs.
So depending on whether you have a GPU or not run the appropriate .cmd file
create-pytorch-gpu-environment.cmd or create-pytorch-cpu-environment.cmd
Lets Verify The Installation…
After the above step you should already be in the PyTorch-CPU or PyTorch-GPU environment.
start Python interpreter
paste the following…
this will output whether PyTorch has access to a GPU and is using it or not.
now paste the entire example below…
from __future__ import print_function
x = torch.rand(5, 3)
A Tensor with random values will be printed on the screen.
Yay! The PyTorch Installation has been verified and working.
Next Step — Lets Run Our Favourite MNIST CNN Example
type the following…
> python pytorch-mnist-cnn.py
This will train the CNN model for 10 epochs and test it and print the accuracy.
Getting small baby steps right to get started are necessary to build Rome one day, sometime in the future.
This is our Website http://automatski.com