Category Archives: PyTorch

Determining If Two Sentences Are Paraphrases Of Each Other Using Hugging Face

Deep neural systems based on Transformer Architecture (TA) have revolutionized the field of natural language processing (NLP). Unfortunately, TA systems are insanely complex, meaning that implementing a TA system from scratch is not feasible, and implementing TA using a low-level … Continue reading

Posted in PyTorch | Leave a comment

A Simplified Approach for Ordinal Classification

In a standard classification problem, the goal is to predict a class label. For example, in the Iris Dataset problem, the goal is to predict a species of flower: 0 = “setosa”, 1 = “versicolor”, 2 = “virginica”. Here the … Continue reading

Posted in PyTorch | Leave a comment

Example of Computing Kullback-Leibler Divergence for Continuous Distributions

In this post, I present an example of estimating the Kullback-Leibler (KL) divergence between two continuous distributions using the Monte Carlo technique. Whoa! Just stating the problem has a massive amount of information. The KL divergence is the key part … Continue reading

Posted in Machine Learning, PyTorch | Leave a comment

Example of a PyTorch Custom Layer

When I create neural software systems, I most often use the PyTorch library. The Keras library is very good for basic neural systems but for advanced architectures I like the flexibility of PyTorch. Using raw TensorFlow without Keras is an … Continue reading

Posted in PyTorch | Leave a comment

An Example of a Bayesian Neural Network Using PyTorch

A regular neural network has a set of numeric constants called weights which determine the network output. If you feed the same input to a regular trained neural network, you will get the same output every time. In a Bayesian … Continue reading

Posted in PyTorch | Leave a comment

Ordinal Classification for the Boston Housing Dataset Using PyTorch

Ordinal classification, also called ordinal regression, is a multi-class classification problem where the class labels to predict are ordered, for example, 0 = “poor”, 1 = “average”, 2 = “good”. You could just do normal classification, but then you don’t … Continue reading

Posted in PyTorch | Leave a comment

Boston Housing Dataset Regression Using PyTorch

The Boston Housing dataset is a standard benchmark for regression algorithms. The goal of the Boston Housing problem is to predict the median price of a house in one of 506 towns near Boston. There are 13 predictor variables — … Continue reading

Posted in PyTorch | 1 Comment

An Example Of The skorch Library For PyTorch

Writing deep neural network code using the PyTorch library is quite difficult. The skorch (“scikit” + “torch”) library provides wrapper code over PyTorch code that is intended to make using PyTorch easier. The skorch library gives an interface like, and … Continue reading

Posted in PyTorch | Leave a comment

Dataset Similarity Using Autoencoded Jensen-Shannon Distance

A problem that pops up over and over in machine learning and data science scenarios is the need to compute the similarity (or nearly equivalently, difference or distance) between two datasets. At first thought, this doesn’t seem difficult, but the … Continue reading

Posted in PyTorch | Leave a comment

Dealing With PyTorch Library Versioning

It’s a major challenge to deal with the compatibility of the dozens of Python based libraries needed to work with the PyTorch neural network library. I was currently using PyTorch version 1.8 (for CPU) along with the Anaconda3-2020.02 distribution which … Continue reading

Posted in PyTorch | Leave a comment