View uses the same data chunk from the original tensor, just a different way to ‘view’ its dimension.
Before we dive into the discussion about what does contiguous vs. non-contiguous mean, we need to first understand the relations between Tensor and View in Pytorch.
View is nothing but an alternative way to interpret the original tensor’s dimension without making a physical copy in the memory. For example, we can have a 1x12 tensor, i.e. [1,2,3,4,5,6,7,8,9,10,11,12] and then use
.view(4,3) to change the shape of the tensor into a 4x3 structure.
x = torch.arange(1,13) print(x) >> tensor([ 1, 2, 3, 4…
Have you ever felt confused about how the tensor dimension works, especially when you need to apply operations like
sum() over high dimension? The technique you learn in this post not only works for tensor dimension, but also works for Numpy ndarray dimension, because the logic of multi-dimensional array/tensor are the same.
This post is going to solve the puzzle in your head once and for good. It will provide you:
sum()works on tensor dimension.
First, tensor is just another…
Striding is like taking steps with a given window size in the data. It is a very common technique which you will see in all kinds of data processing tasks. This tutorial will introduce the most basic concept of Stride, and how to use it in Numpy, and finally wrap up with a Pandas dataframe data processing use case.
In a nutshell, you will be introduced:
If you are a Python user, you must be familiar with Jupyter Notebook. The good news is Google has a cloud based service called CoLab. It is just like running Jupyter Notebook on Google Drive. No need to apply for additional accounts, and no need to apply for the service. All you need is a Google Drive account, and that’s it. Easy & Simple! The best thing is that it gives users free TPU access to run your task! …
I was struggling quite a bit while I started to use VSCode, because there is a lot of flexibility in VSCode, but it also implies that there is tons of detailed settings which allows all kinds of alternative usages. This post is going to introduce the head-to-toe process of how to use Conda environment in VSCode. The post would focus on Windows system, but the other OS users would find it useful too.
As the primary language I use is Python, I will use Python configuration in this demo, and let’s first look at two ways of running Python code…
Ontario Tech University