Questions tagged [pytorch]
PyTorch is an open-source deep learning framework and API that creates a Dynamic Computational Graph, which allows you to flexibly change the way your neural network behaves on the fly and capable is of performing automatic backward differentiation.
17,135
questions
0
votes
0
answers
5
views
Pytorch lstmcell funcinality to work as lstm
Im trying to get get the same functionality of pytorch lstm using pytorch lstm cell.
can you assist?
so i can call a new defined lstm method with the same arguments as calling lstm but in using ...
0
votes
0
answers
11
views
Why is retain_graph = True demanded and what could be impeding learning?
I am building a small application in PyTorch to predict average total value of a property based on categorical and numerical fields. From what I've researched, retain_graph should only be set to True ...
0
votes
0
answers
7
views
No CMAKE_CUDA_COMPILER could be found when installing pytorch
I am trying to install pytorch from source. The reason why I am doing this (instead of just pip install pytorch) is because I need the sm_86 support for my GPU (NVIDIA GTX 3060 Ti) and so I have set ...
0
votes
0
answers
4
views
i want to change something in the learner.recorder.plot_losses function in fastai
I have a task where i need to only plot the training loss not the validation loss of the plot_losses function in the fastai library with learner object having recorder class, but I'm not able to ...
-1
votes
0
answers
9
views
`torch.cuda.Event()` throws error `TypeError: object.__new__() takes exactly one argument (the type to instantiate)`
I'm trying to measure the time of some code in torch, but am unable to instantiate torch.cuda.Event. The documentation doesn't suggest that any parameters are needed, and the same exact line is ...
0
votes
0
answers
6
views
MMSegmentation - ValueError: size shape must match input shape. Input is 2D, size is 3
I get this error when I run the train.py in MMSeg.
File "/usr/local/envs/open-mmlab/lib/python3.7/site-packages/torch/nn/functional.py", line 3473, in interpolate
"size shape must match ...
0
votes
0
answers
12
views
OSError libtorch_global_deps.so: cannot open shared object file: No such file or directory
I am trying to replicate the experiments from https://github.com/QData/spacetimeformer.
After creating the environment and running the script provided in the Example Spacetimeformer Training Commands ...
0
votes
0
answers
11
views
Pytorch lightning validation set has different image sizes than training set
When i try to train a cnn, I get different shapes for the same dataloader and i dont know why. This is the output of the shapes I feed into the model:
You can see that my validation shape is [batch ...
1
vote
0
answers
15
views
Load model weights error : invalid load key in load_state_dict
I'm trying to load weights from a previous model doing :
w_load = torch.load('../models/config_13_split_1_fold_2.h5')
self.model.load_state_dict(w_load, strict=False)
Results in:
['/home/manon/...
-1
votes
1
answer
14
views
Giving two inputs to as single model and concatenating them
I have a model that takes one image as input and it works fine. now I want to give one more transformed image with the same dimensions as the first one as input to the model. The model should learn ...
0
votes
1
answer
9
views
Transforms.Normalize returns values higher than 255 Pytorch
I am working on an video dataset, I read the frames as integers and convert them to a numpy array float32.
After being loaded, they appear in a range between 0 and 255:
[165., 193., 148.],
[166.,...
0
votes
1
answer
14
views
MSELoss from Pytorch
I am trying to train a neural network using Pytorch. I would like the loss function to be the MSE. I tried to use torch.nn.MSELoss, however I get an error that I do not understand.
For example the ...
0
votes
0
answers
16
views
BERT WITH BiDirectional LSTM loss is not decreasing
I am trying port Keras Semantic Similarity example to Pytorch Lightening. I followed all the necessary steps from keras example but somehow loss not at all decreasing. i am just curious where did i ...
0
votes
0
answers
8
views
#Multitask# Training two tasks based on shared features leads to one task failed to converge, but spliting the features for training works fine. How?
Problem statement
Dear all, I encountered the above problem concerning multi-task learning. What does this phenomenon indicate? Does it mean the upper-most features contribute little to the main task? ...
0
votes
0
answers
16
views
PyTorch Dataset Not found error. Can someone help me please?
I am trying to train a dataset locally using yolov5 but it keeps throwing "Dataset not found" exceptions I also tried changing the paths to absolute paths but it still throws the exception. ...
0
votes
1
answer
15
views
An error while trying to implement a polynomial regression with Pytorch - Gradients are None after loss.backward()
I am trying to implement a custom polynomial regression using PyTorch but during the training procedure my implementation fails to calculate the gradients; i.e. the weights are always None even after ...
0
votes
0
answers
8
views
how can I fix such error while calling InferenceSession
I'm trying to run inference of the onnx model with onnxruntime but I got this error while calling InferenceSession.
I successfully export fasterRcnn github model with resnet101 as a backbone (...
0
votes
0
answers
15
views
How to copy the neural network in papers for benchmark experiments?(GAN model)
I want to change the model below:
https://github.com/w86763777/pytorch-gan-collections/blob/master/source/models/dcgan.py
And I want to test the model below:
So I have to change the code to match the ...
0
votes
0
answers
7
views
Process exits with status 139 when trying to instantiate a SentenceTransformer
Description
Hi all, I'm running into a strange error while trying to run the following:
import sentence_transformers as st
encoder = st.SentenceTransformer("all-mpnet-base-v2") # also tried ...
0
votes
1
answer
12
views
pytorch - model.named_parameters() returns 0 after optimizer.zero_grad() step
I am trying to store the weights of the model. The code is given below:
for step, batch in enumerate(train_dataloader):
outputs = model(**batch)
loss = outputs.loss
loss = loss / args....
0
votes
1
answer
31
views
Externally add a Variable to a model in TensorFlow
I have an existing TensorFlow model, and I want to add a new "parameter" (a tf.Variable) to the model's list of parameters (such that it's trainable) and add it externally to the model's ...
1
vote
1
answer
17
views
What is the different for torchvision.models.resnet and torch.hub.load?
There are two method for using resnet of pytorch.
methods 1:
import torch
model = torch.hub.load('pytorch/vision:v0.10.0', 'resnet50', pretrained=True)
model.eval()
methods 2:
import torch
net = ...
1
vote
1
answer
25
views
What is the alternative of pytorch module.register_parameter(name, param) in tensorflow?
I'm trying to convert some pytorch code to tensorflow. In the pytorch code they are adding some extra parameter on every module of a model using module.register_parameter(name, param). How can i ...
0
votes
0
answers
15
views
Converting images to Pytorch tensors loses label data
I have a dataset of images. In the below code, I am trying to convert them to Pytorch tensors by first converting them to PIL images:
# choose the training and test datasets
train_data = os.listdir('...
0
votes
1
answer
11
views
pytorch: simple recurrent neural network for image classification
I am making a simple recurrent neural network architecture for CIFAR10 image classification. I am not interested not use pre-defined RNN class in PyTorch because i am implementing from scratch ...
0
votes
0
answers
11
views
Checkpoint_callback not working in pytorch-lighting version 1.6.3
With pytorch-lighting version 1.2.5 this code saved the top 1 checkpoints during training
checkpoint_callback = ModelCheckpoint(
dirpath='checkpoints',
filename='best-checkpoint',
...
0
votes
0
answers
7
views
winerror 126 after running exe file generated using pyinstaller
I have a python program running without issue, and I tried to generate an exe file for the deployment using pyinstaller. The exe file was also generated successfully, but when I run the exe file, and ...
0
votes
1
answer
14
views
FileNotFoundError in module easyocr when running exe file
I am trying to run exe file and scan picture with easyocr, but here's occurs the error. Could someone help me, please?
Traceback (most recent call last):
File "threading.py", line 954, in ...
0
votes
0
answers
12
views
Convert RNN network to LSTM
I am trying to learn about RNN and LSTM neural networks. I have the following RNN working:
import torch.nn as nn
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
...
0
votes
2
answers
17
views
Selecting entries of a pytorch tensor with another tensor
I have a tensor a with with float entries and torch.Size([64,2]) and I also have a tensor b with torch.Size([64]). The entries of b are only 0 or 1.
I would like to get a new tensor c with torch.Size([...
1
vote
3
answers
30
views
Steps for Machine Learning in Pytorch
When we define our model in PyTorch. We run through different #epochs. I want to know that in the iteration of epochs.
What is the difference between the two following snippets of code in which the ...
0
votes
0
answers
8
views
Why test a voice data with model.eval() have inconsistent result?
I have trained a voice classification model and download the model.pt. When I reload the model and test a voice with model.eval() repeatedly, the results are inconsistent. But when I test the voice ...
0
votes
0
answers
12
views
how to solve this problem in question answering Bert model?
I am developing a QA model using bert and I faced this error.
tokenizer = BertTokenizerFast.from_pretrained('asafaya/bert-base-arabic')
model = BertForQuestionAnswering.from_pretrained('asafaya/bert-...
0
votes
0
answers
18
views
Bayesian ANN regression using pyro
I have the below data where I am trying to fit the column 'Diff_t+1' with the 12 input parameters.
I want to implement Bayesian method using Pyro for the same. I don't want to use PyroModule and ...
2
votes
1
answer
25
views
How to resize image tensors
The following is my code where I'm converting every image to PIL and then turning them into Pytorch tensors:
transform = transforms.Compose([transforms.PILToTensor()])
# choose the training and test ...
0
votes
0
answers
18
views
resuming training of pytorch model
hi everyone l’m trying to train a model of neural network on cifar10 (Resnet) when i try to resume my my training using a checkpoint that i saved earlier like this :
!python '/content/drive/MyDrive/...
1
vote
0
answers
17
views
How to use pos_weight argument in BCEWithLogitsLoss for increased precision
I have a binary segmentation problem. The content of my output is either 0 or 1 in a 2D mask . My classes are heavily imbalanced: class 1 occurs 34 times more than class 0. According to the ...
0
votes
1
answer
43
views
How To Limit Python Memory Usage?
Currently i'm working at Python Project, and i have a 2.12 GB model which has to be processed.
This is the code :
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum"...
-1
votes
1
answer
34
views
How do I calculate the mean of values with the same label given by a mask for multi-dimensional data?
My input x is a tensor of [B, C, H, W] dim. B is batch size, C number of channels, H height and W width. I have a mask m of [H, W] dim. For each batch size and each channel I want to use the mask m to ...
0
votes
0
answers
25
views
PyTorch - Multiply 1D tensor across dimension 0 of 5D tensor
So I have this tensor A that is 1-dimensional of length 6 then I have another tensor B that's 5-dimensional and dimension 0 is of shape (6, batch size, 3, 100, 100) . I'm trying to multiply all values ...
0
votes
1
answer
15
views
How to judge a torch.tensor dtype is int or not?
I want to check a Tensor convert from an image is normalized or not, i.e. the dtype is int or float. Is there convenient way to achieve this goal? I do not want an enumerated condition check like a....
0
votes
0
answers
12
views
How can I include sequence length in my LSTM model input
I am planning to implement a CNN plus LSTM model in Pytorch for a time-series dataset. I am using a pre-trained AlexNet and then passing the output to the LSTM as input. My data are 2344 RGB images ...
0
votes
0
answers
5
views
How to get gpu data from torch.multiprocessing.Queue?
Here is my code:
import torch
import torch.multiprocessing as mp
mp.set_start_method('spawn', force=True)
def job(device, q, event):
x = torch.ByteTensor([1,9,5]).to(device)
x.share_memory_()...
0
votes
0
answers
11
views
Understanding an Einsum usage for graph convolution
I am reading the code for the spatial-temporal graph convolution operation here:
https://github.com/yysijie/st-gcn/blob/master/net/utils/tgcn.py and I'm having some difficulty understanding what is ...
0
votes
0
answers
7
views
How can I combine different objects in npz file
I have an .npz file which includes data
['X_test', 'X_train', 'y_train', 'y_test']
But I need a file such as;
['train','test']
In order to do that actually I want to combine X_test with y_test, and ...
0
votes
0
answers
8
views
how to aggregate tensors based on another tensor in Pytorch
Assume we have two input tensors named emb and mention, we need an algorithm to aggregate emb based on mention. Here is an example:
# Inputs:
emb = tc.tensor([[float(i)] * 4 for i in range(1, 17)], ...
0
votes
0
answers
42
views
How to split neural network parameters into groups
I have the following neural network toy example:
class Neural_net(nn.Module):
def __init__(self):
super(Neural_net, self).__init__()
self.fc1 = nn.Linear(2, 2)
...
0
votes
0
answers
4
views
Pytorch Obtaining Probability For a Model
I have a pretrained model, GoogleNet which I used to detect lung cancer. After seeking for help on the internet, I managed to find a method to detect whether the image given has cancer or not. However,...
0
votes
0
answers
5
views
How to extract the encoded features after running a PyTorch LSTM autoencoder model?
I am very new to PyTorch and Python in general, and I am now struggling to get the encoded features from my pre-trained LSTM autoencoder which can be seen below:
import torch
import torch.nn as nn
# ...
0
votes
1
answer
16
views
How to visualize the peaks in a signal with window size
I am trying to visualize some signal peaks with window size. but it doesn't give the right result I expect. This is my code below
'''
def extract_beat(signal, qrs_pos, win_msec=40, fs=360, start_beat=...