Category Archives: PyTorch

Computing PCA Using NumPy Without Scikit

Principal component analysis (PCA) is a classical statistics technique that can do data dimensionality reduction. This can be used to graph high dimensional data (if you reduce the dim to 2), or to clean data (by reconstructing the data from … Continue reading

Posted in Machine Learning, PyTorch | 1 Comment

Sentiment Analysis Using a PyTorch EmbeddingBag Layer in Visual Studio Magazine

I wrote an article titled “Sentiment Analysis Using a PyTorch EmbeddingBag Layer” in the July 2021 edition of the online Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2021/07/06/sentiment-analysis.aspx. Natural language processing (NLP) problems are very difficult. A common type of NLP problem … Continue reading

Posted in Machine Learning, PyTorch | Leave a comment

Creating a Custom Python Vocabulary Object From Scratch For NLP Problems

I’ve been looking at natural language processing (NLP) problems on-and-off for quite some time. One weekend I decided to implement a custom Vocabulary class from scratch. A Vocabulary object accepts a word/token and returns a unique integer ID. For example, … Continue reading

Posted in Machine Learning, PyTorch | Leave a comment

Logistic Regression Using PyTorch with L-BFGS in Visual Studio Magazine

I wrote an article titled “Logistic Regression Using PyTorch with L-BFGS” in the June 2021 edition of the online Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2021/06/23/logistic-regression-pytorch.aspx. Logistic regression is one of many machine learning techniques for binary classification — predicting one … Continue reading

Posted in PyTorch | Leave a comment

Sentiment Analysis using a PyTorch Neural Network with an EmbeddingBag Layer

In computer science, and life, it helps to be smart but it’s also important to have determination. I’m not the smartest guy in the Universe, but once a problem gets stuck in my head it will stay there until it … Continue reading

Posted in PyTorch | 2 Comments

Serving Up PyTorch Training Data Using The DataLoader collate_fn Parameter

When creating a deep neural network, writing code to prepare the training data and serve it up in batches to the network is almost always difficult and time consuming. A regular PyTorch DataLoader works great for tabular style data where … Continue reading

Posted in PyTorch | Leave a comment

Generating Synthetic Data Using a Generative Adversarial Network (GAN) with PyTorch in Visual Studio Magazine

I wrote an article titled “Generating Synthetic Data Using a Generative Adversarial Network (GAN) with PyTorch” in the June 2021 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2021/06/02/gan-pytorch.aspx. A generative adversarial network (GAN) is a deep neural system that can … Continue reading

Posted in PyTorch | Leave a comment

Combining Logistic Regression Models by Averaging Their Weights

Suppose you want to make a logistic regression binary classification model, for example to predict if a hospital patient is male or female based on variables such as age and hospitalization history. And suppose your training data file is very … Continue reading

Posted in PyTorch | Leave a comment

Creating a PyTorch Vocabulary Object for Natural Language Processing Problems

Even the simplest natural language processing problem is extremely difficult. With a basic neural network classifier, you usually have to normalize numeric data (such as dividing a person’s age by 100) and encode non-numeric data (e.g., “red” = 1,0,0) but … Continue reading

Posted in PyTorch | Leave a comment

Knowing When To Stop Training a Generative Adversarial Network (GAN)

A generative adversarial network (GAN) is a deep neural system that is designed to generate fake/synthetic data items. A GAN has a clever architecture made of two neural networks: a generator that creates fake data items, and a discriminator that … Continue reading

Posted in PyTorch | Leave a comment