# Tag: Python

• ## VSCode and Docker for Machine Learning

In this article, I want to share my experience using Visual Studio Code (VSCode) for all my machine learning work and how it has significantly improved my productivity. I believe that I am now five times more productive than before, thanks to the use of VSCode, Docker containers, and GitHub Copilot. Working in Different Environments: […]

• ## In Pytorch what is nn.Embedding for and how is it different from One Hot Encding for representing categorical data

In PyTorch, nn.Embedding is a class that provides a simple lookup table that maps integers (usually representing discrete items like words, tokens, or categories) to continuous vectors. It is primarily used for working with categorical data in deep learning models, particularly in natural language processing tasks. nn.Embedding is often used to convert discrete tokens (e.g., […]

• ## What is the PyTorch permute() function for?

In PyTorch, the permute() function is used to rearrange the dimensions of a tensor according to a specified order. This can be useful in various deep learning scenarios, such as when you need to change the dimension order of your input data to match the expected input format of a model. The function takes a […]

• ## Pairwise Squared Euclidean Distance Loss function used in “Taming Transformers for high resolution images” paper explained

The code snippet using PyTorch library below is found in the Taming Transformers paper: This code snippet is performing a vectorized calculation to compute pairwise squared Euclidean distances between two sets of vectors: z_flattened and the rows of self.embedding.weight. Let’s break down the code: Now let’s analyze the calculations: Finally, the code adds the three […]

• ## What is tensor.detach() used for in PyTorch?

Let’s take a closer look at the detach() function in PyTorch, which plays a helpful role when working with Tensors. The detach() function creates a new Tensor that shares the same data as the original one but without the attached computation history. This essentially separates the new Tensor from the computation graph, making it independent […]

• ## What does the tensor.view() function do in PyTorch and how is it different from permute?

In PyTorch, the view() function is a tensor operation used to reshape a tensor without changing its underlying data. It allows you to change the dimensions of a tensor to fit your desired shape while preserving the original data and maintaining the same number of elements. This is especially useful when you need to change […]

• ## Visualizing a neural network in 3D with Python, Blender and Tensorflow

I have started recently a new project in which I am trying to visualize a neural network in 3D with Python, Blender and Tensorflow. This is a very interesting challenge and a great way to learn things that I didn’t know I needed to know. For example how to get access to the different layers […]

• ## Convert a photo from 2D to 3D model with color with PIFu

This is a short tutorial on how you can convert and train Pifu to convert a 2D photo to a 3D Model with color. Pifu is the predecessor to PIFuHD.  PIFU in theory can be trained to create 3D Models for any type of object, not just humans, but of course, you will need to […]