Category "pytorch"

Solving "CUDA out of memory" when fine-tuning GPT-2 (HuggingFace)

I get the reoccuring CUDA out of memory error when using the HuggingFace Transformers library to fine-tune a GPT-2 model and can't seem to solve it, despite my

Pytorch model weights change when put on GPU

I noticed a very strange behaviour regarding the 3D Resnet by Facebookresearch. Using their sample code from the website, I receive different results, when putt

I this the correct way of computing the average accuracy?

I am fairly new to coding and getting confused between average accuracy and overall accuracy. I have created a function to calculate accuracy, i then divide thi

list' object has no attribute 'to' in trainer function in torch to(self.device)

class Trainer: def __init__(self, modelName,model,train_partial_dataset, val_dataset, loss_function, optimizer,path_save_best_model,device):

RuntimeError: Found dtype Long but expected Float when fine-tuning using Trainer API

I'm trying to fine-tune BERT model for sentiment analysis (classifying text as positive/negative) with Huggingface Trainer API. My dataset has two columns, Text

Got: TypeError: 'bool' object is not callable when building CNN using PyTorch

I got the following error when using PyTorch to build a convolutional neural network TypeError: 'bool' object is not callable. Attached is the related code: cla

DQN doesn't learn

I'm trying to implement a DQN in CarPole environment using Pytorch. I don't know why, but no matter how long I've tried to train the agent, even though the scor

Batch Kronecker product of tensors

I have two tensors that are batches of matrices: x = torch.randn(100,10,10) y = torch.randn(100,2,2) I want to parallelize the kronecker on each matrix, not d

Path for loading PyTorch model in Java with DJL

I trained a custom PyTorch model and saved it as a .pt file. I'm now trying to load this model in Java using DJL. Path modelDir = Paths.get("/Users/myname/eclip

How to download an older version of PyTorch Geometric in Google Colab?

Question: How can I download an older version of PyTorch geometric in google colab? Context: I am trying to use/load a pytorch-geometric graph and am getting th

How to get the actual learning rate in PyTorch?

I'm trying to find the appropriate learning rate for my Neural Network using PyTorch. I've implemented the torch.optim.lr_scheduler.CyclicLR to get the learning

Why is my Pytorch code significantly slower than Tensorflow?

I am trying to move my code from Tensorflow to Pytorch. Before doing this, I just simply test myself two frameworks. I expected two frameworks should show simil

Upgrade CUDNN to 8.2 in google colab

I wan to use upgrade the CUDNN version from 8.0 to 8.1 and CUDA version to 11.2, but I am not sure how we can do this on colab. Below is the script I wrote to r

How to solve "RuntimeError: CUDA error: invalid device ordinal"?

I'm trying to run this code. I don't know what is wrong with it, but this code is not running. and I don't know how to solve this problem. import cv2 from facia

Gradio - Pytorch MNIST Digit Recognizer

I watched the following video on YouTube https://www.youtube.com/watch?v=jx9iyQZhSwI where it was shown that it is possible to use Gradio and the learned model

PytorchStreamReader failed reading zip archive: failed finding central directory

I am trying to learn pytorch from a book, but it seems not a straight line for me. I coped the code below and pasted in my jupyter notebook for running but it g

Monai : RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 7 but got size 8 for tensor number 1 in the list

I am using Monai for the 3D Multilabel segmentation task. My input image size is 512x496x49 and my label size is 512x496x49. An Image can have 3 labels in one i

Reproducibility issue with PyTorch

I'm running a script with the same seed and I see results are reproduced on consecutive runs but somehow running the same script with the same seed changes the

Access all batch outputs at the end of epoch in callback with pytorch lightning

The documentation for the on_train_epoch_end, https://pytorch-lightning.readthedocs.io/en/stable/extensions/callbacks.html#on-train-epoch-end, states: To acces

Assigning custom weights to embedding layer in PyTorch

Does PyTorch's nn.Embedding support manually setting the embedding weights for only specific values? I know I could set the weights of the entire embedding laye