Introduction to PyTorch on Windows

I wrote an article titled “Introduction to PyTorch on Windows” in the January 2019 issue of Microsoft MSDN Magazine. See https://msdn.microsoft.com/en-us/magazine/mt848704.

Among my colleagues, the most commonly used neural network libraries are TensorFlow, Keras, CNTK, and, increasingly, PyTorch. I like all these libraries but I find myself using PyTorch more and more often. Like all the libraries, PyTorch has a non-trivial learning curve. But once you get over the initial hurdles, PyTorch has a very nice feel to it (and don’t ask me to explain what I mean by that because I can’t).

Here’s a screenshot of the demo program for the article:

The demo program reads the well-known Iris dataset into memory. The goal is to predict the species of an Iris flower (setosa, versicolor or virginica) from four predictor values: sepal length, sepal width, petal length and petal width. A sepal is a leaf-like structure.

The complete Iris dataset has 150 items. The demo program uses 120 items for training and 30 items for testing. The demo first creates a neural network using PyTorch, then trains the network using 600 iterations. After training, the model is evaluated using the test data. The trained model has an accuracy of 90.00 percent, which means the model correctly predicts the species of 27 of the 30 test items.

The demo concludes by predicting the species for a new, previously unseen Iris flower that has sepal and petal values (6.1, 3.1, 5.1, 1.1). The prediction probabilities are (0.0454, 0.6798, 0.2748), which maps to a prediction of versicolor.

In the last paragraph of my article, I give an opinion:

A common question is, “Which neural network library is best?” In a perfect world you could dedicate time and learn all the major libraries. But because these libraries are quite complicated, realistically most of my colleagues have one primary library. In my opinion, from a technical point of view, the three best libraries are CNTK, Keras/TensorFlow and PyTorch. But they’re all excellent and picking one library over another really depends mostly on your programming style and which one is most used by your colleagues or company.



PyTorch – torch – tiki torch – hula – hula girl lamp. Hula girl lamps were first popularized in the late 1920s. They were made by the Dodge Company (not the auto maker) — the company that made the first Oscar statues for the motion picture Academy Awards, and still makes them today. Some of the old lamps are very valuable.

This entry was posted in PyTorch. Bookmark the permalink.