From the course: PyTorch Essential Training: Deep Learning

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Tensor data types

Tensor data types

- [Instructor] What sets PyTorch apart from other libraries is the usage of tensors, multidimensional arrays that can seamlessly perform fast operations on GPUs and distribute operations on multiple machines while keeping track of the graphic computations that created them. Let's look at the various tensor data types that are used in computations happening in neural networks. We'll start by importing PyTorch and creating a couple of tensor objects. We are going to create our first one-dimensional tensor and call it int_tensor, and specify the data type by using dtype as an argument to the constructor. We want all tensor elements to be integer type of eight-bit size, so we'll type dtype=torch.int8. Let's displace data type using dtype function. Now let's create a second one-dimensional tensor and call it float_tensor. We want all tensor elements to be 32 floating points, so we'll type dtype=torch.float32 and just display the data type. What if we want to create a one-dimensional tensor…

Contents