Skip to main content

All Questions

0 votes
1 answer
68 views

Unable to return a boolean variable from Pytorch Dataset's __get_item__

I have a pytorch Dataset subclass and I create a pytorch DataLoader out of it. It works when I return two tensors from DataSet's __getitem__() method. I tried to create minimal (but not working, more ...
MsA's user avatar
  • 3,007
1 vote
0 answers
427 views

How to use parallel torch cuda streams without causing oom? (example included)

I'm storing a large amount of tensors data in a cpu memory, and the intended workflow is to process them using the GPU. And while one chunk is being processed, simultaneously transfer the previous ...
Anonymous's user avatar
  • 4,630
1 vote
1 answer
156 views

Pytorch `DataSet.__getitem__()` called with `index` bigger than `__len__()`

I have following torch dataset (I have replaced actual code to read data from files with random number generation to make it minimal reproducible): from torch.utils.data import Dataset import torch ...
Mahesha999's user avatar
1 vote
0 answers
29 views

PyTorch's Linear layer not training

I am trying to implement a Deep Embedded Self-Organizing Map (DESOM) which is an Autoencoder together with a trainable SOM as a trainable layer which I implement using a Linear layer: class SOM(nn....
Arun's user avatar
  • 2,498
0 votes
2 answers
1k views

Huggingface pipeline available models

I'm working with Huggingface in Python to make inference with specific LLM text generation models. So far I used pipelines like this to initialize the model, and then insert input from a user and ...
Cardstdani's user avatar
  • 5,243
1 vote
2 answers
496 views

Gradients for selection from array operation in PyTorch

This is a followup question from here. I have obtained a tensor, say, d with gradients. Now I have another tensor array, say e from which I need to pick the first d elements. MWE below. import torch ...
learner's user avatar
  • 3,482
2 votes
2 answers
413 views

Pass gradients through min function in PyTorch

I have a variable, say, a which has some gradient associated with it from some operations before. Then I have integers b and c which have no gradients. I want to compute the minimum of a, b, and c. ...
learner's user avatar
  • 3,482
0 votes
1 answer
37 views

LSTM layer followed by BatchNorm Layer error in dimensions

I am trying to train a model with the following architecture : self.lstm1 = nn.LSTM(in_channels, hidden_channels, num_layers, batch_first=True, dropout=dropout_prob) self.batchnorm1 = nn.BatchNorm1d(...
Zenon Lambrou's user avatar
1 vote
1 answer
919 views

Calculating the Fisher metric in PyTorch

Given some simple PyTorch model, how do I compute the Fisher Metric? Here's a (useless for practical purposes) trivial model which uses a single linear layer to solve the matrix equation Ax=b, where A ...
notastringtheorist's user avatar
1 vote
1 answer
1k views

how to rename classes of trained model in Pytorch

I've trained my object detection model based on YOLOV7 and YOLOV5. Now, for some reason i need to change name of classes. Is it possible to change classes names and save it again as Pytorch ML model ...
livan3li's user avatar
  • 969
0 votes
0 answers
30 views

while installing dependencies from the repo its giving me error

here are the dependencies required to run this simple repository on my mac book for tiny face detection in python and it's giving me errors while installing the requirements.txt file here is the error ...
Saeedanwar Mehmood's user avatar
0 votes
1 answer
344 views

Got TypeError when adding return_indices=True to nn.MaxPool2d in pytorch

I am New to pyotch, i am trying to create an autoencoder in pytorch, here is my code The encoder: # B = Batch size # encoder (B, 3, 224, 224) => (B, 8) class Encoder(nn.Module): def __init__(...
monstar's user avatar
2 votes
1 answer
371 views

Saving the model architecture with activation functions in PyTorch

I use PyTorch for training neural networks. While saving the model, the weights of the network are saved, while the activation functions are not captured. Now, I reload the model from the saved ...
learner's user avatar
  • 3,482
3 votes
3 answers
4k views

KeyError: 'eval_loss' in Hugginface Trainer

I am trying to build a Question Answering Pipeline with the Hugginface framework but facing the KeyError: 'eval_loss' error. My goal is to train and save the best model at last and evaluate the ...
Aaditya Ura's user avatar
  • 12.7k
0 votes
1 answer
233 views

RuntimeError: mat1 and mat2 shapes cannot be multiplied (1x7 and 1x1)

I faced this issue when I tried to train the model. This model is meant to predict Celsius to Fahrenheit. Do help me to review my code below: # this file is a simple example of how to use pytorch to ...
James Wong's user avatar

15 30 50 per page
1
2 3 4 5 6