Category "pytorch"

How to apply max_length to truncate the token sequence from the left in a HuggingFace tokenizer?

In the HuggingFace tokenizer, applying the max_length argument specifies the length of the tokenized text. I believe it truncates the sequence to max_length-2 (

How to clean garbage from CUDA in Pytorch?

I teached my neural nets and realized that even after torch.cuda.empty_cache() and gc.collect() my cuda-device memory is filled. In Colab Notebooks we can see t

Pytorch Change the learning rate based on number of epochs

When I set the learning rate and find the accuracy cannot increase after training few epochs optimizer = optim.Adam(model.parameters(), lr = 1e-4) n_epochs = 1

Padding a tensor until reaching required size

I'm working with certian tensors with shape of (X,42) while X can be in a range between 50 to 70. I want to pad each tensor that I get until it reaches a size o

Exception when converting Unet from pytorch to onnx

I'm trying to convert a Unet model from PyTorch to ONNX. Running the following code: import torch from unets import Unet, thin_setup net = Unet(in_features=3,

How to resize a PyTorch tensor?

I have a PyTorch tensor of size (5, 1, 44, 44) (batch, channel, height, width), and I want to 'resize' it to (5, 1, 224, 224) How can I do that? What functions

Pytorch: How to compute IoU (Jaccard Index) for semantic segmentation

Can someone provide a toy example of how to compute IoU (intersection over union) for semantic segmentation in pytorch?

What is the time-complexity of the pseudo-inverse in pytorch (i.e. torch.pinverse)?

Let's say I have a matrix X with n, m == X.shape in PyTorch. What is the time complexity of calculating the pseudo-inverse with torch.pinverse? In other words,

Why do we need to call zero_grad() in PyTorch?

Why does zero_grad() need to be called during training? | zero_grad(self) | Sets gradients of all model parameters to zero.

Why do we need to call zero_grad() in PyTorch?

Why does zero_grad() need to be called during training? | zero_grad(self) | Sets gradients of all model parameters to zero.

libtorch and pytorch cannot be installed simultaneously?

I am learning to develop with PyTorch as well as LibTorch. I have the following line in my ~/.bashrc for dynamic linking of libtorch libraries: # libtorch linki

How does calculation in a GRU layer take place

So I want to understand exactly how the outputs and hidden state of a GRU cell are calculated. I obtained the pre-trained model from here and the GRU layer has

how do i solve Key 8 error while using pytorch?

from torch.utils.data import (TensorDataset, DataLoader, RandomSampler, SequentialSampler) def data_loader(train_inputs, val_inp

Pytorch unable to export trained model as ONNX

I have been training a model in the Pytorch framework using multiple convolutional layers (3x3, stride 1, padding same). The model performs well and I want to u

How to fix 'The kernel appears to have died. It will restart automatically" caused by pytorch

I have a strange problem with Pytorch. When i use something torch functions with tensors like tensor.rehsape or torch.transpose, i don't have problem and all o

Some parameters are not getting saved when saving a model in pytorch

I have built an encoder-decoder model with attention for morph inflection generation. I am able to train the model and predict on test data but I am getting wro

Torch sum a tensor along an axis

How do I sum over the columns of a tensor? torch.Size([10, 100]) ---> torch.Size([10])

Pytorch with CUDA local installation fails

I am trying to install PyTorch with CUDA. I followed the instructions (installation using conda) mentioned in https://pytorch.org/get-started/locally/ conda in

How to upscale image in pytorch?

how to upscale an image in Pytorch without defining height and width using transforms? ('--upscale_factor', type=int, required=True, help="super resolution ups

numpy equivalent code of unsqueeze and expand from torch tensor method

I have these 2 tensors box_a = torch.randn(1,4) box_b = torch.randn(1,4) and i have a code in pytorch box_a[:, 2:].unsqueeze(1).expand(1, 1, 2) but i want to