How to see which python line causes a cuda crash down the line in Pytorch, which executes asynchronous code outside of the GIL? Here is a case where I had Pytorch crash cuda, running this code on this dataset and every run would crash with the debugger on a different python line, making it very difficult to debug. Answer I
Tag: pytorch
Appling sliding window to torch.tensor and adjusting tensor initial size
Looking for a simpler way of torch.tensor modification. Probably there is a way to apply Unfold to initial tensor directly. input: output: possible solution: Answer You can use unfold, but in a simpler manner:
HTTPS POST to query FastAPI using python requests
I am trying to serve a Neural Network using FastAPI. The manual site http://localhost:8000/docs#/default/predict_predict_post works fine and translates into the following curl command: which also works. When I try to query the API using python requests: I only get the “422 Unprocessable Entity” Errors. Where am I going wrong here? Answer You provide a data argument to requests.post, which does
ValueError: Expected x_max for bbox (0.65, 0.51, 1.12, 0.64, 3) to be in the range [0.0, 1.0], got 1.1234809015877545
I want to apply data augmentations from PyTorch’s Albumentations to images with bounding boxes. When I apply the HorizontalFlip Transformation, I receive this error ValueError: Expected x_max for bbox (0.6505353259854019, 0.517013871576637, 1.1234809015877545, 0.6447916687466204, 3) to be in the range [0.0, 1.0], got 1.1234809015877545. I use the following code When I apply the Cutout transformation, I do not have any error
Scale down image represented in a tensor
I use the MNIST dataset to learn Pytorch. This is from the documentation to get a picture. Tensor comes from the torchvision dataset. This is the Tensor: I want to scale the image down to a 14×14 picture, so I guess I need a torch.Size([1, 14, 14]) I tried this, but it results in a different format: I expected this
Pytorch: 1D target tensor expected, multi-target not supported
I want to train a 1D CNN on time series. I get the following error message 1D target tensor expected, multi-target not supported Here is the code with simulated data corresponding to the structures of my data as well as the error message Error message: What am I doing wrong? Answer You are using nn.CrossEntropyLoss as the criterion for your
using ModuleList, still getting ValueError: optimizer got an empty parameter list
With Pytorch I am attempting to use ModuleList to ensure model parameters are detected, and can be optimized. When calling the SGD optimizer I get the following error: ValueError: optimizer got an empty parameter list Can you please review the code below and advise? Answer This seems to be a copy-paste issue: your __init__ has 3 underscores instead of 2,
Torch: Why is this collate function so much faster than this other one?
I have developed two collate functions to read in data from h5py files (I tried to create some synthetic data for a MWE here but it is not going to plan). The difference between the two in processing my data is about 10x — a very large increase and I am unsure as to why and I am curious for
Why do sometimes CNN models predict just one class out of all others?
I am relatively new to the deep learning landscape, so please don’t be as mean as Reddit! It seems like a general question so I won’t be giving my code here as it doesn’t seem necessary (if it is, here’s the link to colab) A bit about the data: You can find the original data here. It is a downsized
Why is the code not able to approximate the square function?
WHy does the following code not work as a square approximator? I am getting weird dimensions. When I tried plotting loss, the graph somehow does not show anything. I am a beginner with pytorch, so I would be grateful for any help. Answer Your data is ranging from -10000 to 10000! You need to standardize your data, otherwise you won’t