id stringlengths 7 11 | source stringclasses 1
value | category stringclasses 11
values | title stringlengths 15 214 | text stringlengths 70 30.5k | url stringlengths 57 160 | tags stringlengths 3 113 | created_at int64 1.22B 1.79B |
|---|---|---|---|---|---|---|---|
se_57986783 | stackoverflow | MACHINE_LEARNING | embedding layer outputs nan | embedding layer outputs nan
I am trying to learn a seq2seq model.
An embedding layer is located in the encoder and it sometimes outputs nan value after some iterations.
I cannot identify the reason.
How can I solve this??
The problem is the first emb_layer in the forward function in the code below.
class Transformer... | https://stackoverflow.com/questions/57986783/embedding-layer-outputs-nan | deep-learning, pytorch, transformer-model, seq2seq | 1,568,789,992 |
se_79416003 | stackoverflow | MACHINE_LEARNING | Lowpass filter is slower on GPU than CPU in PyTorch | Lowpass filter is slower on GPU than CPU in PyTorch
I have been trying out some of the Torchaudio functionalities and I can't seem to figure out why lowpass_biquad is running slower on the GPU than on the CPU. And this is true for other effects like, phaser, flanger, overdrive, which are even slower. Here I am pasting... | https://stackoverflow.com/questions/79416003/lowpass-filter-is-slower-on-gpu-than-cpu-in-pytorch | python, audio, pytorch, torchaudio | 1,738,784,102 |
se_79417996 | stackoverflow | MACHINE_LEARNING | efficient matrix inversion/multiplication with multiple batch dimensions in pytorch | efficient matrix inversion/multiplication with multiple batch dimensions in pytorch
In my framework, I am having an outer loop (here mocked by the variable n) and inside the loop body I have to perform matrix inversions/multiplications for multiple batch dimensions. I observed that manually looping over the batch dime... | https://stackoverflow.com/questions/79417996/efficient-matrix-inversion-multiplication-with-multiple-batch-dimensions-in-pyto | python, pytorch, batch-processing | 1,738,846,926 |
se_79419131 | stackoverflow | MACHINE_LEARNING | PermissionError: [Errno 13] Permission denied (Slurm) | PermissionError: [Errno 13] Permission denied (Slurm)
I am currently running on my university's computing nodes to train my pytorch model. My data is on the University's remote filesystem as well. I have num_workers>0 and multiple runs going on in parallel. Although I have never had this problem before, now all of my ... | https://stackoverflow.com/questions/79419131/permissionerror-errno-13-permission-denied-slurm | python, pytorch, remote-server, slurm | 1,738,870,356 |
se_79417066 | stackoverflow | MACHINE_LEARNING | Element wise multiplication of scalars with matrix | Element wise multiplication of scalars with matrix
In this example, I want to multiply each of the 10 (batch size) 3x3 matrices with the corresponding scalar. Is there a better solution without having to unsqueeze twice?
import torch
# Create a batch of scalars (e.g., 10 scalars)
batch_size = 10
scalars = torch.randn... | https://stackoverflow.com/questions/79417066/element-wise-multiplication-of-scalars-with-matrix | pytorch, elementwise-operations | 1,738,826,694 |
se_78107928 | stackoverflow | MACHINE_LEARNING | 'MistralForCausalLM' object has no attribute 'merge_and_unload" | 'MistralForCausalLM' object has no attribute 'merge_and_unload"
I finetuned (or further pretrained) the Model OpenChat (a Mistral 7B finetuning) on my own data. This worked well and the inference produces nice results. Now I want to merge the adapter weights with the original model, to quantize the mo... | https://stackoverflow.com/questions/78107928/mistralforcausallm-object-has-no-attribute-merge-and-unload | python, pytorch, huggingface-transformers, peft, mistral-7b | 1,709,643,804 |
se_79355967 | stackoverflow | MACHINE_LEARNING | HuggingFace Pretrained Model for Fine-Tuning has 100% Trainable Parameters | HuggingFace Pretrained Model for Fine-Tuning has 100% Trainable Parameters
I believe I’m correctly following HuggingFace’s documentation on fine-tuning pretrained models, but I get a model with 100% trainable parameters. I thought only some layers would be unfrozen and optimized, but it looks like all of them are.
def... | https://stackoverflow.com/questions/79355967/huggingface-pretrained-model-for-fine-tuning-has-100-trainable-parameters | pytorch, huggingface-transformers, fine-tuning | 1,736,878,196 |
se_79389502 | stackoverflow | MACHINE_LEARNING | Abnormal cuda and cpu memory usage with huggingface transformers ViT-msn model | Abnormal cuda and cpu memory usage with huggingface transformers ViT-msn model
There are basically two parts to the question, the first part is that while inferring on the model and storing minimal results, the python app takes up around 3GB of memory on my system ( i have hardcoded device='cpu'), this is unexpected a... | https://stackoverflow.com/questions/79389502/abnormal-cuda-and-cpu-memory-usage-with-huggingface-transformers-vit-msn-model | python, pytorch, out-of-memory, huggingface-transformers | 1,737,935,807 |
se_60519297 | stackoverflow | MACHINE_LEARNING | RuntimeError: Could not run 'aten::xxxx', Can't load Pytorch model trained with TPU | RuntimeError: Could not run 'aten::xxxx', Can't load Pytorch model trained with TPU
Training for MLM was added based on the Japanese model of BERT.
At that time, we used TPU on Google Colab.
I get the following error when loading the created model.
Is there a way to load the model?
from transformers import... | https://stackoverflow.com/questions/60519297/runtimeerror-could-not-run-atenxxxx-cant-load-pytorch-model-trained-with | pytorch | 1,583,297,730 |
se_79415897 | stackoverflow | MACHINE_LEARNING | Python doesn't see torch | Python doesn't see torch
I am trying to run python using Jupyter-lab locally.
I installed PyTorch on my Mac using brew. However pip doesn't see it and so does python
I installed PyTorch using pipx
python inside Jupyter doesn't see torch and neither does python from the command line
In Jupyter I see this -
--------... | https://stackoverflow.com/questions/79415897/python-doesnt-see-torch | python, pytorch, pip | 1,738,781,874 |
se_79415785 | stackoverflow | MACHINE_LEARNING | How to apply min-max scaling on a IterableDataset? | How to apply min-max scaling on a IterableDataset?
I'm using an iterableDataset because I have massive amounts of data. And since IterableDataset does not store all data in memory, we cannot directly compute min/max on the entire dataset before training. That is because for min-max we need to calculate the min x value... | https://stackoverflow.com/questions/79415785/how-to-apply-min-max-scaling-on-a-iterabledataset | pytorch, scaling, iterable, pytorch-lightning, pytorch-dataloader | 1,738,779,545 |
se_74591729 | stackoverflow | MACHINE_LEARNING | easyocr not working with cpu only on Windows | easyocr not working with cpu only on Windows
I was succesful using easyocr on my computer with gpu and cuda, but now I have to use it also on machine with only cpu.
After following the installation guide from https://www.jaided.ai/easyocr/install/ and installing pytorch from https://pytorch.org/get-started/locally/ ch... | https://stackoverflow.com/questions/74591729/easyocr-not-working-with-cpu-only-on-windows | python, pytorch, ocr, easyocr | 1,669,566,114 |
se_75929010 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'pytorch_lightning.core.decorators' | Google Colab GPU session | ModuleNotFoundError: No module named 'pytorch_lightning.core.decorators' | Google Colab GPU session
In my Google Colab GPU runtime, I try to install pytorch_lightning. So I do the following in the order:
!pip list | grep torch
torch 2.0.0+cu118
torchaudio 2.0.1+cu118
... | https://stackoverflow.com/questions/75929010/modulenotfounderror-no-module-named-pytorch-lightning-core-decorators-googl | pytorch, importerror, pytorch-lightning | 1,680,608,903 |
se_79413251 | stackoverflow | MACHINE_LEARNING | PyTorch's seq2seq tutorial decoder | PyTorch's seq2seq tutorial decoder
I am learning through PyTorch's seq2seq tutorial: https://pytorch.org/tutorials/intermediate/seq2seq_translation_tutorial.html
I have a question about the decoder
class DecoderRNN(nn.Module):
def __init__(self, hidden_size, output_size):
super(DecoderRNN, self).__init... | https://stackoverflow.com/questions/79413251/pytorchs-seq2seq-tutorial-decoder | python, machine-learning, pytorch, recurrent-neural-network, seq2seq | 1,738,710,104 |
se_79413456 | stackoverflow | MACHINE_LEARNING | YOLO11 failing with C++ ops error on M3 Mac - PyTorch/MPS issue? | YOLO11 failing with C++ ops error on M3 Mac - PyTorch/MPS issue?
I'm having issues trying to get YOLOv11 working with PyTorch MPS on apple silicon. Keep getting this C++ ops error and can't figure out what's wrong.
Here's my setup:
M3 Pro MacBook
Python 3.9
torch 2.6.0
torchvision 0.21.0
torchaudio 2.6.0
ultralytics ... | https://stackoverflow.com/questions/79413456/yolo11-failing-with-c-ops-error-on-m3-mac-pytorch-mps-issue | python, c++, pytorch, yolo, apple-silicon | 1,738,719,324 |
se_73880706 | stackoverflow | MACHINE_LEARNING | RuntimeError: Error compiling objects for extension while installing detectron2 | RuntimeError: Error compiling objects for extension while installing detectron2
I’m trying to install detectron2 on my local machine. A cpp_extension.py located in
C:\Users\Username\miniconda3\envs\pytorch_env\lib\site-packages\torch\utils\cpp_extension.py
fails to compile and throws a
raise RuntimeError(message) f... | https://stackoverflow.com/questions/73880706/runtimeerror-error-compiling-objects-for-extension-while-installing-detectron2 | compiler-errors, pytorch, runtime-error, miniconda, detectron | 1,664,364,851 |
se_79411478 | stackoverflow | MACHINE_LEARNING | How to interpret differences in accuracy curves after applying different data augmentations in CNN training? | How to interpret differences in accuracy curves after applying different data augmentations in CNN training?
I trained a CNN for emotion recognition and used two different transformation pipelines for image preprocessing:
Simple Transformation:
TRANSFORM = transforms.Compose([
transforms.Resize((64, 64)),
tran... | https://stackoverflow.com/questions/79411478/how-to-interpret-differences-in-accuracy-curves-after-applying-different-data-au | python, pytorch, conv-neural-network, preprocessor | 1,738,667,620 |
se_79409259 | stackoverflow | MACHINE_LEARNING | How does Hydra `_partial_` interact with seeding | How does Hydra `_partial_` interact with seeding
In the configuration management library Hydra, it is possible to only partially instantiate classes defined in configuration using the _partial_ keyword. The library explains that this results in a functools.partial. I wonder how this interacts with seeding. E.g. with
... | https://stackoverflow.com/questions/79409259/how-does-hydra-partial-interact-with-seeding | python, machine-learning, pytorch, pytorch-lightning, fb-hydra | 1,738,596,536 |
se_79411033 | stackoverflow | MACHINE_LEARNING | `grouped_gemm` Installation Error: PyTorch Version Mismatch and Possible Forced CUDA 12.4 Dependency | `grouped_gemm` Installation Error: PyTorch Version Mismatch and Possible Forced CUDA 12.4 Dependency
When deploying the multimodal model ARIA (https://huggingface.co/rhymes-ai/Aria), I need to install the grouped_gemm acceleration framework to speed up the model's inference.
When running pip install grouped_gemm==0.1.... | https://stackoverflow.com/questions/79411033/grouped-gemm-installation-error-pytorch-version-mismatch-and-possible-forced | pytorch, windows-subsystem-for-linux | 1,738,657,794 |
se_62351295 | stackoverflow | MACHINE_LEARNING | How to gradually train a model on transformers library? | How to gradually train a model on transformers library?
I have seen this tutorial on how to train a BERT model from scratch on Hugging Face Transformers library.
I'm trying to train a GPT-2 model on 1.5 GB data on Google Colab. I load up all the data using this code:
dataset = LineByLineTextDataset(
tokenizer=t... | https://stackoverflow.com/questions/62351295/how-to-gradually-train-a-model-on-transformers-library | python, tensorflow, nlp, pytorch, huggingface-transformers | 1,591,990,655 |
se_49768306 | stackoverflow | MACHINE_LEARNING | Pytorch tensor to numpy array | Pytorch tensor to numpy array
I have a pytorch Tensor of shape [4, 3, 966, 1296]. I want to convert it to numpy array using the following code:
imgs = imgs.numpy()[:, ::-1, :, :]
How does that code work? | https://stackoverflow.com/questions/49768306/pytorch-tensor-to-numpy-array | python, numpy, pytorch | 1,523,429,362 |
se_79408930 | stackoverflow | MACHINE_LEARNING | Lightning Tensorboard Hparams tab not showing custom metric | Lightning Tensorboard Hparams tab not showing custom metric
I'm training a neural network built with pyTorch Lightning and I'm trying to have the HParams tab working in tensorboard.
Following the official outdated guide I initialize the logger with default_hp_metric=False:
logger = TensorBoardLogger("lightning_logs", ... | https://stackoverflow.com/questions/79408930/lightning-tensorboard-hparams-tab-not-showing-custom-metric | deep-learning, pytorch, neural-network, tensorboard, pytorch-lightning | 1,738,588,332 |
se_76199099 | stackoverflow | MACHINE_LEARNING | How to build pytorch/xla (from source) on Windows 11 WSL | How to build pytorch/xla (from source) on Windows 11 WSL
I am attempting to build Pytorch/XLA on a new Windows 11 laptop (16" Lenovo AMD Ryzen Ideapad 5 pro to be specific) under WSL (Ubuntu 22.04) following the Linux instructions at https://github.com/pytorch/pytorch#from-source.
However, no matter what I try, I get ... | https://stackoverflow.com/questions/76199099/how-to-build-pytorch-xla-from-source-on-windows-11-wsl | c++, linux, cmake, pytorch, windows-subsystem-for-linux | 1,683,536,966 |
se_79355662 | stackoverflow | MACHINE_LEARNING | Is combining pytorch and ProcessPoolExecutor doable? | Is combining pytorch and ProcessPoolExecutor doable?
I have created a structure, which provided a dataset as opts to a ProcessPoolExecutor and the inputs are the indices for the dataset.
I could provide a MWE, but I tried several approaches and all resulted in something like a Forkbomb.
I think the cause was some inte... | https://stackoverflow.com/questions/79355662/is-combining-pytorch-and-processpoolexecutor-doable | pytorch, parallel-processing | 1,736,871,679 |
se_79380954 | stackoverflow | MACHINE_LEARNING | CUDA Out of Memory During Backpropagation on Multi-GPU Setup (PyTorch) | CUDA Out of Memory During Backpropagation on Multi-GPU Setup (PyTorch)
I am implementing a training loop using two NVIDIA RTX 3090 GPUs (each with 24 GB memory). My setup involves loading a large sparse matrix (approximately 6 GB) on one GPU (device_matrix) and the model on another GPU (device_net). However, when I ru... | https://stackoverflow.com/questions/79380954/cuda-out-of-memory-during-backpropagation-on-multi-gpu-setup-pytorch | deep-learning, pytorch, out-of-memory, multi-gpu | 1,737,633,703 |
se_79402407 | stackoverflow | MACHINE_LEARNING | RuntimeError with PyTorch when Fine-tuning LLM: "element 0 of tensors does not require grad" | RuntimeError with PyTorch when Fine-tuning LLM: "element 0 of tensors does not require grad"
I'm trying to fine-tune a LLaMA model using LoRA, but I'm getting the following error during training:
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
Code
Here's my training set... | https://stackoverflow.com/questions/79402407/runtimeerror-with-pytorch-when-fine-tuning-llm-element-0-of-tensors-does-not-r | python, machine-learning, pytorch, llama, fine-tuning | 1,738,318,313 |
se_79401912 | stackoverflow | MACHINE_LEARNING | How to specify gradient computation path in a neural network in pytorch | How to specify gradient computation path in a neural network in pytorch
I want to implement a neural network on pytorch where gradients are not computed over all the weights. Let's say for example I have an MLP with three layers and I want half of the nodes in the last layer to have their backpropagation computed all ... | https://stackoverflow.com/questions/79401912/how-to-specify-gradient-computation-path-in-a-neural-network-in-pytorch | python, deep-learning, pytorch, gradient-descent | 1,738,304,340 |
se_52465723 | stackoverflow | MACHINE_LEARNING | What is the difference between parameters and children? | What is the difference between parameters and children?
It looks like parameters and children show the same info, so what is the difference between them?
import torch
print('torch.__version__', torch.__version__)
m = torch.load('imagenet_resnet18.pth')
print(m.parameters)
print(m.children) | https://stackoverflow.com/questions/52465723/what-is-the-difference-between-parameters-and-children | python, pytorch | 1,537,702,591 |
se_72899079 | stackoverflow | MACHINE_LEARNING | What do BatchNorm2d's running_mean / running_var mean in PyTorch? | What do BatchNorm2d's running_mean / running_var mean in PyTorch?
I'd like to know what exactly the running_mean and running_var that I can call from nn.BatchNorm2d.
Example code is here where bn means nn.BatchNorm2d.
vector = torch.cat([
torch.mean(self.conv3.bn.running_mean).view(1), torch.std(self.conv3.bn.... | https://stackoverflow.com/questions/72899079/what-do-batchnorm2ds-running-mean-running-var-mean-in-pytorch | deep-learning, pytorch, mean, variance, batch-normalization | 1,657,201,989 |
se_79400482 | stackoverflow | MACHINE_LEARNING | Map each element of torch.Tensor with it's value in the dict | Map each element of torch.Tensor with it's value in the dict
Suppose i have a tensor t consisting only zeros and ones:
t = torch.Tensor([1, 0, 0, 1])
And a dict with the weights:
weights = {0: 0.1, 1: 0.9}
I want to form a new tensor new_t, such that every element in tensor t is mapped to the corresponding value i... | https://stackoverflow.com/questions/79400482/map-each-element-of-torch-tensor-with-its-value-in-the-dict | python, dictionary, pytorch, mapping, tensor | 1,738,252,622 |
se_77145031 | stackoverflow | MACHINE_LEARNING | Pytroch clamp for complex values | Pytroch clamp for complex values
I am trying to use clamp but it isn't working because I have a mix of complex and real values. Is there something that works the same as clamp but for real and complex values? I've tried looking some up and haven't gotten anything other than clamp. | https://stackoverflow.com/questions/77145031/pytroch-clamp-for-complex-values | python, pytorch | 1,695,233,535 |
se_79399217 | stackoverflow | MACHINE_LEARNING | Can batch normalization be considered a linear transformation? | Can batch normalization be considered a linear transformation?
A deep neural network f consists of one fully connected network and one batch normalization layer. (e.g., f = FCN + BN)
Given a dataset with inputs x and y, can the following property hold?
f(x+y) = f(x) + f(y)
I think the fully connected network natural... | https://stackoverflow.com/questions/79399217/can-batch-normalization-be-considered-a-linear-transformation | tensorflow, deep-learning, pytorch, normalization | 1,738,225,616 |
se_79396894 | stackoverflow | MACHINE_LEARNING | Doing PyWavelets calculation on GPU | Doing PyWavelets calculation on GPU
Currently working on a classifier using PyWavelets, here is my calculation block:
class WaveletLayer(nn.Module):
def __init__(self):
super(WaveletLayer, self).__init__()
def forward(self, x):
def wavelet_transform(img):
coeffs = pywt.dwt2(img.cpu... | https://stackoverflow.com/questions/79396894/doing-pywavelets-calculation-on-gpu | python, machine-learning, deep-learning, pytorch, haar-wavelet | 1,738,157,189 |
se_79397701 | stackoverflow | MACHINE_LEARNING | Unable to find candidates for torch | Unable to find candidates for torch
So I am trying to install torch on one of my projects and my specs are as below
Python 3.12.3 /
pip latest /
Poetry (version 2.0.1)/
I am on Apple M3 Max
Here is my pyproject.toml
torch = { version = "^2.5.1+cpu", source = "pytorch-cpu" }
torchvision = { version = "^0.20.1+cpu", sou... | https://stackoverflow.com/questions/79397701/unable-to-find-candidates-for-torch | python, macos, pytorch, python-poetry | 1,738,173,017 |
se_64320883 | stackoverflow | MACHINE_LEARNING | The size of tensor a (707) must match the size of tensor b (512) at non-singleton dimension 1 | The size of tensor a (707) must match the size of tensor b (512) at non-singleton dimension 1
I am trying to do text classification using pretrained BERT model. I trained the model on my dataset, and in the phase of testing; I know that BERT can only take to 512 tokens, so I wrote if condition to check the length of t... | https://stackoverflow.com/questions/64320883/the-size-of-tensor-a-707-must-match-the-size-of-tensor-b-512-at-non-singleto | python, tensorflow, pytorch, tokenize, bert-language-model | 1,602,516,858 |
se_77587542 | stackoverflow | MACHINE_LEARNING | PyTorch multiprocessing is filling up shared memory. Is there any way to manually invoke torch_shm_manager to garbage collect? | PyTorch multiprocessing is filling up shared memory. Is there any way to manually invoke torch_shm_manager to garbage collect?
I'm trying to process input data in parallel so it can be loaded into a PyTorch dataset. However, when it reaches ~20,000 data points or so, the parallel processes crash claiming it can't all... | https://stackoverflow.com/questions/77587542/pytorch-multiprocessing-is-filling-up-shared-memory-is-there-any-way-to-manuall | python, pytorch, multiprocessing | 1,701,457,767 |
se_65445174 | stackoverflow | MACHINE_LEARNING | What is the difference between an Embedding Layer with a bias immediately afterwards and a Linear Layer in PyTorch | What is the difference between an Embedding Layer with a bias immediately afterwards and a Linear Layer in PyTorch
I am reading the "Deep Learning for Coders with fastai & PyTorch" book. I'm still a bit confused as to what the Embedding module does. It seems like a short and simple network, except I can't seem to wrap... | https://stackoverflow.com/questions/65445174/what-is-the-difference-between-an-embedding-layer-with-a-bias-immediately-afterw | python, oop, deep-learning, pytorch, fast-ai | 1,608,868,923 |
se_79275704 | stackoverflow | MACHINE_LEARNING | How to properly convert Detectron2 instance segmentation (Mask R-CNN) model to onnx model | How to properly convert Detectron2 instance segmentation (Mask R-CNN) model to onnx model
I'm trying to convert a Detectron2 model to onnx. When I try to run the onnx model afterwards I get the following error:
Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from /dbfs/redacted/model_simp.onnx failed:Node (If_3504) O... | https://stackoverflow.com/questions/79275704/how-to-properly-convert-detectron2-instance-segmentation-mask-r-cnn-model-to-o | pytorch, onnx, detectron | 1,734,017,772 |
se_55441939 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'torch._C' | ModuleNotFoundError: No module named 'torch._C'
I want to import the torch,but then the interpreter return this result,i have no idea how to deal with it
Traceback (most recent call last):
File "D:/Programing/tool/Python/learn_ml_the_hard_way/ML/scipy1.py", line 1, in <module>
import torch
File "D:\P... | https://stackoverflow.com/questions/55441939/modulenotfounderror-no-module-named-torch-c | pytorch | 1,554,042,606 |
se_52138920 | stackoverflow | MACHINE_LEARNING | Why do we normalize the image to mean=0.5, std=0.5? | Why do we normalize the image to mean=0.5, std=0.5?
I was lookking for GAN code in Github. The code I found uses pytorch. In this code, we first normalized the image to mean = 0.5, std = 0.5. Normally, normalize to min = 0 and max = 1. Or normal distribution with mean = 0 and std = 1. Why is this normalized to mean = ... | https://stackoverflow.com/questions/52138920/why-do-we-normalize-the-image-to-mean-0-5-std-0-5 | python, tensorflow, deep-learning, computer-vision, pytorch | 1,535,905,616 |
se_53623472 | stackoverflow | MACHINE_LEARNING | How do I display a single image in PyTorch? | How do I display a single image in PyTorch?
How do I display a PyTorch Tensor of shape (3, 224, 224) representing a 224x224 RGB image?
Using plt.imshow(image) gives the error:
TypeError: Invalid dimensions for image data | https://stackoverflow.com/questions/53623472/how-do-i-display-a-single-image-in-pytorch | python, matplotlib, pytorch | 1,543,969,981 |
se_65138643 | stackoverflow | MACHINE_LEARNING | Examples or explanations of pytorch dataloaders? | Examples or explanations of pytorch dataloaders?
I am fairly new to Pytorch (and have never done advanced coding). I am trying to learn the basics of deep learning using the d2l.ai textbook but am having trouble with understanding the logic behind the code for dataloaders. I read the torch.utils.data docs and am not s... | https://stackoverflow.com/questions/65138643/examples-or-explanations-of-pytorch-dataloaders | python, pytorch, dataloader | 1,607,061,404 |
se_79389115 | stackoverflow | MACHINE_LEARNING | How to map values from a 3D tensor to a 1D tensor in PyTorch? | How to map values from a 3D tensor to a 1D tensor in PyTorch?
I'm stuck with a Pytorch problem and could use some help:
I've got two tensors:
A 3D tensor (shape: i, j, j) with integer values from 0 to n
A 1D tensor (shape: n)
I need to create a new tensor that's the same shape as the first one (i, j, j), but where e... | https://stackoverflow.com/questions/79389115/how-to-map-values-from-a-3d-tensor-to-a-1d-tensor-in-pytorch | python, indexing, pytorch, tensor, torch | 1,737,917,510 |
se_79388667 | stackoverflow | MACHINE_LEARNING | Pretrained VGG16 model performs so poor on ImageNet-V2 testset | Pretrained VGG16 model performs so poor on ImageNet-V2 testset
I am trying to build my model using the pretrained VGG16 model on ImageNet-V1 dataset in Pytorch. I loaded the model and tested it with ImageNet-V2 matched frequency testset. The problem is the accuracy is so low, just 1.14%. Here is my code:
import torch
... | https://stackoverflow.com/questions/79388667/pretrained-vgg16-model-performs-so-poor-on-imagenet-v2-testset | deep-learning, pytorch, pre-trained-model, vgg-net | 1,737,901,138 |
se_79389412 | stackoverflow | MACHINE_LEARNING | ImportError:Cannot Allocate Memory in Static TLS Block | ImportError:Cannot Allocate Memory in Static TLS Block
Reposting because I didn't solve my problem:
I am encountering the following error message when attempting to run my code:
ImportError: /home/orin_nano1/.local/lib/python3.8/site-packages/torch/lib/…/…/torch.libs/libgomp-804f19d4.so.1.0.0: cannot allocate memory i... | https://stackoverflow.com/questions/79389412/importerrorcannot-allocate-memory-in-static-tls-block | python, ubuntu, pytorch, nvidia-jetson | 1,737,930,499 |
se_79351470 | stackoverflow | MACHINE_LEARNING | install pytorch for cuda 12.6 | install pytorch for cuda 12.6
how to install pytorch for cuda 12.6? it is available till 12.4. but when I install 12.4, it installed. but it is showing kernel restarting issue in jupyter notebook. please help.
can you please suggest methods to overcome this problem | https://stackoverflow.com/questions/79351470/install-pytorch-for-cuda-12-6 | python, python-3.x, pytorch, cuda, gpu | 1,736,754,486 |
se_77960052 | stackoverflow | MACHINE_LEARNING | torch.cuda.OUtOfMemoryError: CUDA out of memory. Tried to allocate xxx MiB | torch.cuda.OUtOfMemoryError: CUDA out of memory. Tried to allocate xxx MiB
This is the error I got when I use pytorch to train my nerf model, which shows during the backward pass:
Traceback (most recent call last):
File "train_dmsr.py", line 133, in <module>
train()
File "train_dmsr.py", line 64, in train
... | https://stackoverflow.com/questions/77960052/torch-cuda-outofmemoryerror-cuda-out-of-memory-tried-to-allocate-xxx-mib | pytorch, gpu, out-of-memory | 1,707,379,108 |
se_71056529 | stackoverflow | MACHINE_LEARNING | Which shap explainer should be used for multimodal input (image data and tabular data)? | Which shap explainer should be used for multimodal input (image data and tabular data)?
I want to try explaining the decisions of a model in pytorch with 2 inputs of image and tabular data like it is used in this tutorial (https://rosenfelder.ai/multi-input-neural-network-pytorch/)
If I do want to interpret such a mod... | https://stackoverflow.com/questions/71056529/which-shap-explainer-should-be-used-for-multimodal-input-image-data-and-tabular | python, pytorch, shap | 1,644,439,783 |
se_69184856 | stackoverflow | MACHINE_LEARNING | Hypergraph Convolution using Pytorch Geometric: RuntimeError: index 2268264 is out of bounds for dimension 0 with size 2268264 | Hypergraph Convolution using Pytorch Geometric: RuntimeError: index 2268264 is out of bounds for dimension 0 with size 2268264
I am trying to use the Pytorch-geometric hypergraph convolution network's layer for training on hypergraph datasets. I am using the Amazon review dataset provided by https://www.cs.cornell.edu... | https://stackoverflow.com/questions/69184856/hypergraph-convolution-using-pytorch-geometric-runtimeerror-index-2268264-is-o | python, machine-learning, graph, deep-learning, pytorch | 1,631,656,083 |
se_79387312 | stackoverflow | MACHINE_LEARNING | Low GPU Utilization on Pytorch without obvious bottlenecks | Low GPU Utilization on Pytorch without obvious bottlenecks
I am running training on a rather simple deep learning network (~800kb).
LSTM with 2 layers and 128 neurons,
Feed Forward with 2 linear layers and 64 neurons,
Final Feed forward with 2 linear layers and 64 neurons,
However, I am getting low GPU utilization at ... | https://stackoverflow.com/questions/79387312/low-gpu-utilization-on-pytorch-without-obvious-bottlenecks | python, machine-learning, pytorch, gpu, nvidia | 1,737,830,923 |
se_79386418 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'torch.utils' | ModuleNotFoundError: No module named 'torch.utils'
I am pretty new to coding and recently I've been trying to train a recognition model for real time recognition through the computer's webcam. This is the video I am following: https://www.youtube.com/watch?v=fZiY7zUk3TU. However, as soon as I go to train the m... | https://stackoverflow.com/questions/79386418/modulenotfounderror-no-module-named-torch-utils | python, windows, deep-learning, pytorch, modulenotfounderror | 1,737,794,317 |
se_53894496 | stackoverflow | MACHINE_LEARNING | Traceback (most recent call last) in Colab when looping through dataloader in pytorch | Traceback (most recent call last) in Colab when looping through dataloader in pytorch
I'm working on a project to classify flower images using a pre-trained model vgg19 using pytorch.
I'm relying on the model features only and using a custom classifier.
However on starting a for-loop to feed images to the model clas... | https://stackoverflow.com/questions/53894496/traceback-most-recent-call-last-in-colab-when-looping-through-dataloader-in-py | python, python-3.x, deep-learning, pytorch, vgg-net | 1,545,470,919 |
se_79383301 | stackoverflow | MACHINE_LEARNING | Is there a way to use list of indices to simultaneously access the modules of nn.ModuleList in python? | Is there a way to use list of indices to simultaneously access the modules of nn.ModuleList in python?
Is there a way to use list of indices to simultaneously access the modules of
nn.ModuleList in python?
I am working with pytorch ModuleList as described below,
decision_modules = nn.ModuleList([nn.Linear(768, 768) fo... | https://stackoverflow.com/questions/79383301/is-there-a-way-to-use-list-of-indices-to-simultaneously-access-the-modules-of-nn | python, list, pytorch, pytorch-dataloader, pytorch-geometric | 1,737,696,471 |
se_78660414 | stackoverflow | MACHINE_LEARNING | Print torch tensor without extra spacing in between scalars | Print torch tensor without extra spacing in between scalars
There is a huge space in between elements of my tensors when printing. I cannot read the tensor easily with this space.
How do I minimize it?
print settings I used:
torch.set_printoptions(sci_mode=False, precision=4, linewidth=200, profile="full")
np.set_prin... | https://stackoverflow.com/questions/78660414/print-torch-tensor-without-extra-spacing-in-between-scalars | numpy, pytorch, pretty-print | 1,719,198,875 |
se_79382515 | stackoverflow | MACHINE_LEARNING | OutOfMemoryError with PatchCore Training on 23.67 GiB GPU | OutOfMemoryError with PatchCore Training on 23.67 GiB GPU
I’m training a PatchCore model with an image size of 128x512 on a GPU with 23.67 GiB memory. However, I’m encountering the following error:
CUDA Version: 12.4
PyTorch Version: 2.5.1
OutOfMemoryError: CUDA out of memory. Tried to allocate 2.17 GiB. GPU 0 has a t... | https://stackoverflow.com/questions/79382515/outofmemoryerror-with-patchcore-training-on-23-67-gib-gpu | memory-management, pytorch, gpu, out-of-memory | 1,737,664,785 |
se_79382816 | stackoverflow | MACHINE_LEARNING | How to multiply 2x3x3x3 matrix by 2x3 matrix to get 2x3 matrix | How to multiply 2x3x3x3 matrix by 2x3 matrix to get 2x3 matrix
I am trying to compute some derivatives of neural network outputs. To be precise I need the jacobian matrix of the function that is represented by the neural network and the second derivative of the function with respect to its inputs.
I want to multiply t... | https://stackoverflow.com/questions/79382816/how-to-multiply-2x3x3x3-matrix-by-2x3-matrix-to-get-2x3-matrix | python, pytorch, matrix-multiplication, autograd | 1,737,673,084 |
se_51136581 | stackoverflow | MACHINE_LEARNING | How do I create a normal distribution in pytorch? | How do I create a normal distribution in pytorch?
I want to create a random normal distribution with a given mean and std. | https://stackoverflow.com/questions/51136581/how-do-i-create-a-normal-distribution-in-pytorch | python, pytorch, normal-distribution | 1,530,535,567 |
se_70099636 | stackoverflow | MACHINE_LEARNING | How do I use the GPU in a AWS Sagemaker ml.t3.2xlarge instance? | How do I use the GPU in a AWS Sagemaker ml.t3.2xlarge instance?
I have a notebook ml.t3.2xlarge instance on AWS Sagemaker and I want to train a neural network using pytorch.
The following command returns "False":
torch.cuda.is_available()
Is there something I need to do to activate the GPU?
When I run the following c... | https://stackoverflow.com/questions/70099636/how-do-i-use-the-gpu-in-a-aws-sagemaker-ml-t3-2xlarge-instance | python, amazon-web-services, pytorch, amazon-sagemaker | 1,637,771,355 |
se_57858433 | stackoverflow | MACHINE_LEARNING | How to clear GPU memory after PyTorch model training without restarting kernel | How to clear GPU memory after PyTorch model training without restarting kernel
I am training PyTorch deep learning models on a Jupyter-Lab notebook, using CUDA on a Tesla K80 GPU to train. While doing training iterations, the 12 GB of GPU memory are used. I finish training by saving the model checkpoint, but want to c... | https://stackoverflow.com/questions/57858433/how-to-clear-gpu-memory-after-pytorch-model-training-without-restarting-kernel | python, pytorch, jupyter | 1,568,049,131 |
se_62162576 | stackoverflow | MACHINE_LEARNING | Calculating shape of conv1d layer in Pytorch | Calculating shape of conv1d layer in Pytorch
How we can calculate the shape of conv1d layer in PyTorch. IS there any command to calculate size and shape of these layers in PyTorch.
nn.Conv1d(depth_1, depth_2, kernel_size=kernel_size_2, stride=stride_size),
nn.ReLU(),
nn.MaxPool1d(k... | https://stackoverflow.com/questions/62162576/calculating-shape-of-conv1d-layer-in-pytorch | pytorch, size | 1,591,137,984 |
se_79378344 | stackoverflow | MACHINE_LEARNING | Function returns NoneType attribute in case of a large number of parameter inputs | Function returns NoneType attribute in case of a large number of parameter inputs
Full project available at https://github.com/mwp-g/MWPG-DMR
the output
the code
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.
Traceback (most recent call last):
File "pretra... | https://stackoverflow.com/questions/79378344/function-returns-nonetype-attribute-in-case-of-a-large-number-of-parameter-input | python, pytorch, nonetype | 1,737,559,623 |
se_77631329 | stackoverflow | MACHINE_LEARNING | Why can't weight be updated when using detach()? | Why can't weight be updated when using detach()?
I'm programming VGG model for a school project but this model causes problems during training.
If I use detach() to two tensors that is scaled_similarity and target_tensor, the weights of the model are not updated. but if I don't use detach() to the tensors, an erro... | https://stackoverflow.com/questions/77631329/why-cant-weight-be-updated-when-using-detach | python, pytorch, conv-neural-network, artificial-intelligence, vgg-net | 1,702,126,130 |
se_67843192 | stackoverflow | MACHINE_LEARNING | Is it possible to update different rows of a pytorch Tensor in different ways? | Is it possible to update different rows of a pytorch Tensor in different ways?
I've had some trouble even finding any people on the internet with this same issue since its quite hard to phrase concisely.. :/
Essentially my issue is I have a pytorch tensor, call it n:
tensor([[2., 2., 2., 2.],
[2., 2., 2., 2.],... | https://stackoverflow.com/questions/67843192/is-it-possible-to-update-different-rows-of-a-pytorch-tensor-in-different-ways | python, pytorch, tensor | 1,622,836,004 |
se_79378157 | stackoverflow | MACHINE_LEARNING | HuggingFace Model - OnnxRuntime - Jupyter Notebook Print Model Summary | HuggingFace Model - OnnxRuntime - Jupyter Notebook Print Model Summary
Thank you very much for reading my question , sorry if it is an obvious question.
I use anaconda navigator : piped install the model whisper from OpenAi, which is an audio to text transformer model, I use jupyter notebook and when I just run the ce... | https://stackoverflow.com/questions/79378157/huggingface-model-onnxruntime-jupyter-notebook-print-model-summary | pytorch, huggingface, onnx, onnxruntime, openai-whisper | 1,737,556,506 |
se_79378022 | stackoverflow | MACHINE_LEARNING | The “Forward/Backward Passage Size” is too large for the pytorch model (Yolov3) | The “Forward/Backward Passage Size” is too large for the pytorch model (Yolov3)
I'm writing Yolov3 in Pytorch.
Architecture: https://i.sstatic.net/mncjfiDs.png
Code:
class Convolutional(nn.Module): # DBL
def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding=1):
super... | https://stackoverflow.com/questions/79378022/the-forward-backward-passage-size-is-too-large-for-the-pytorch-model-yolov3 | python, machine-learning, deep-learning, pytorch, yolo | 1,737,554,859 |
se_79284426 | stackoverflow | MACHINE_LEARNING | How to manage memory consumption in deep learning models? | How to manage memory consumption in deep learning models?
When I run this code, the runtime session automatically closes. There is no space in RAM left. Hence the session closes automatically. I am using pytorch in Google Colab notebook. I tried switching from CPU to GPU but still the session closes automatically.
!pi... | https://stackoverflow.com/questions/79284426/how-to-manage-memory-consumption-in-deep-learning-models | deep-learning, pytorch, data-science, large-language-model, transfer-learning | 1,734,346,810 |
se_71617570 | stackoverflow | MACHINE_LEARNING | PytorchStreamReader failed reading zip archive: failed finding central directory | 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 copied the code below and pasted in my jupyter notebook.
It gave me an error that I am not able to interpret.
from torchvision import models
model = mode... | https://stackoverflow.com/questions/71617570/pytorchstreamreader-failed-reading-zip-archive-failed-finding-central-directory | python-3.x, pytorch | 1,648,214,106 |
se_78561628 | stackoverflow | MACHINE_LEARNING | Resume finetuning of LLM with LoRA | Resume finetuning of LLM with LoRA
I have fine-tuned a Phi-3 for 1 epoch using LoRA as follows:
self.model=AutoModelForCausalLM.from_pretrained(self.model_args.model_name_or_path,**kwarg)
self.model = get_peft_model(self.model, self.lora_config)
Now I want to resume from existing LoRA weights by loading the weights a... | https://stackoverflow.com/questions/78561628/resume-finetuning-of-llm-with-lora | pytorch, huggingface-transformers, large-language-model | 1,717,180,000 |
se_79062292 | stackoverflow | MACHINE_LEARNING | TypeError: expected np.ndarray (got numpy.ndarray) | TypeError: expected np.ndarray (got numpy.ndarray)
I use the below code and it report error, This is a very simple example and should not report error as expected.
import numpy as np
import torch as th
# Assuming tt is some data (example as list)
tt = [1, 2, 3, 4, 5] # Example data
# Check if tt is a NumPy array, a... | https://stackoverflow.com/questions/79062292/typeerror-expected-np-ndarray-got-numpy-ndarray | python, python-3.x, numpy, pytorch | 1,728,310,164 |
se_79373655 | stackoverflow | MACHINE_LEARNING | Discrepancies between tensorflow and pytorch while maintaining batch size, loss functions, architectures, metric, data, optimizer | Discrepancies between tensorflow and pytorch while maintaining batch size, loss functions, architectures, metric, data, optimizer
It is a follow up question to Investigating discrepancies in TensorFlow and PyTorch performance
The author stated that there is a performance gap between Pytorch and Tensorflow while mainta... | https://stackoverflow.com/questions/79373655/discrepancies-between-tensorflow-and-pytorch-while-maintaining-batch-size-loss | python, tensorflow, machine-learning, pytorch, neural-network | 1,737,448,026 |
se_72962998 | stackoverflow | MACHINE_LEARNING | unable to load torchaudio even after installing | unable to load torchaudio even after installing
I'm trying to use torchaudio but I'm unable to import it. I have installed it and it is also visible through the pip list.
<ipython-input-6-4cf0a64f61c0> in <module>
----> 1 import torchaudio
ModuleNotFoundError: No module named 'torchaudio'
pytorch-lightning 1... | https://stackoverflow.com/questions/72962998/unable-to-load-torchaudio-even-after-installing | pip, pytorch, torchaudio | 1,657,700,255 |
se_79358039 | stackoverflow | MACHINE_LEARNING | Torch Euclidian Norm (L2) | Torch Euclidian Norm (L2)
I am trying to compute the L2 norm between two tensors as part of a loss function, but somehow my loss ends up being NaN and I suspect it it because of the way the L2 norm is computed. Can you please explain me the difference between torch.linalg.vector_norm(x-y) and torch.norm(x-y) functions... | https://stackoverflow.com/questions/79358039/torch-euclidian-norm-l2 | python, pytorch, torch, euclidean-distance, norm | 1,736,940,390 |
se_79369085 | stackoverflow | MACHINE_LEARNING | Does order of transforms applied for data augmentation matter in Torchvision transforms? | Does order of transforms applied for data augmentation matter in Torchvision transforms?
I have the following Custom dataset class for an image segmentation task.
class LoadDataset(Dataset):
def __init__(self, img_dir, mask_dir, apply_transforms = None):
self.img_dir = img_dir
self.mask_dir = mask_... | https://stackoverflow.com/questions/79369085/does-order-of-transforms-applied-for-data-augmentation-matter-in-torchvision-tra | python, pytorch, torchvision, data-augmentation | 1,737,295,335 |
se_79369359 | stackoverflow | MACHINE_LEARNING | Problem in Backpropagation through a sample in Beta distribution in pytorch | Problem in Backpropagation through a sample in Beta distribution in pytorch
Say I have obtained some alphas and betas as parameters from a neural network, which will be parameters of the Beta distribution. Now, I sample from the Beta distribution and then calculate some loss and back-propagate via the samples obtained... | https://stackoverflow.com/questions/79369359/problem-in-backpropagation-through-a-sample-in-beta-distribution-in-pytorch | python, pytorch, gradient-descent, autograd | 1,737,305,561 |
se_78487166 | stackoverflow | MACHINE_LEARNING | Reinforcement Learning Gymnasium ValueError | Reinforcement Learning Gymnasium ValueError
I am testing out reinforcement learning for the first time with gymnasium.
I am following a youtube tutorial.
I am getting the following error when I run the training loop:
ValueError: setting an array element with a sequence. The requested array would exceed the maximum num... | https://stackoverflow.com/questions/78487166/reinforcement-learning-gymnasium-valueerror | python, pytorch, reinforcement-learning, gymnasium | 1,715,823,051 |
se_79367460 | stackoverflow | MACHINE_LEARNING | Converting torch tensor to numpy array using .numpy method gives an error | Converting torch tensor to numpy array using .numpy method gives an error
>>> a = torch.tensor([[1,2,3],[2,3,4],[3,4,5]])
>>> a
tensor([[1, 2, 3],
[2, 3, 4],
[3, 4, 5]])
If we convert this tensor to a numpy array and try to print it, this gives an error
>>> a = a.numpy()
>>> a
AttributeError: module '... | https://stackoverflow.com/questions/79367460/converting-torch-tensor-to-numpy-array-using-numpy-method-gives-an-error | python, numpy, pytorch | 1,737,215,950 |
se_79368015 | stackoverflow | MACHINE_LEARNING | Difference between torch.as_tensor() and torch.asarray() | Difference between torch.as_tensor() and torch.asarray()
What I understand from the docs is that both torch.as_tensor() and torch.asarray() return the tensor that shares the memory with the input data, and return a copy otherwise. I noticed only two differencies in parameteres:
I can implicitly pass copy=False into ... | https://stackoverflow.com/questions/79368015/difference-between-torch-as-tensor-and-torch-asarray | pytorch | 1,737,236,529 |
se_79366566 | stackoverflow | MACHINE_LEARNING | Troubleshooting LSTM Forecasting Function: What am I doing wrong? | Troubleshooting LSTM Forecasting Function: What am I doing wrong?
I have three inputs to my LSTM (x,y,z). My LSTM model is used to predict the next time step of z. I have a lookback period of 9 timesteps. I then need to forecast the next time steps of z using a recursive function. However, I get bad results when I plo... | https://stackoverflow.com/questions/79366566/troubleshooting-lstm-forecasting-function-what-am-i-doing-wrong | pytorch, lstm, forecasting | 1,737,174,918 |
se_79344879 | stackoverflow | MACHINE_LEARNING | How do I run torch.distributed between Docker containers on separate instances using the bridge network? | How do I run torch.distributed between Docker containers on separate instances using the bridge network?
I am trying to run a simple torch.distributed script between two Docker containers running on separate instances. Below is the code I am using:
import os
import torch
import torch.distributed as dist
def init_dist... | https://stackoverflow.com/questions/79344879/how-do-i-run-torch-distributed-between-docker-containers-on-separate-instances-u | python, docker, pytorch, docker-network, gloo | 1,736,493,395 |
se_79365374 | stackoverflow | MACHINE_LEARNING | How to utilize multiple CPUs for training of YOLO? | How to utilize multiple CPUs for training of YOLO?
I have access to a large CPU cluster that does not have GPUs. Is it possible to speed up YOLO training by parallelizing between multiple CPU nodes?
The docs say that device parameter specifies the computational device(s) for training: a single GPU (device=0), multiple... | https://stackoverflow.com/questions/79365374/how-to-utilize-multiple-cpus-for-training-of-yolo | machine-learning, deep-learning, pytorch, cluster-computing, yolo | 1,737,129,946 |
se_79368955 | stackoverflow | MACHINE_LEARNING | Llama 3: Getting a CUDA unknown error while fine tuning Llama 3 on wikitext | Llama 3: Getting a CUDA unknown error while fine tuning Llama 3 on wikitext
I am a beginner in Large Language Models and the Hugging Face API. I was trying to fine tune the Llama 3.1 8b model on the wikitext dataset as practice.
When I try to run the following script, I get an unknown CUDA error.
CUDA error: unknown e... | https://stackoverflow.com/questions/79368955/llama-3-getting-a-cuda-unknown-error-while-fine-tuning-llama-3-on-wikitext | python, pytorch, large-language-model, llama, fine-tuning | 1,737,290,437 |
se_79366420 | stackoverflow | MACHINE_LEARNING | Turn Grayscale mask-image into RGB while changing one grayscale into specific color | Turn Grayscale mask-image into RGB while changing one grayscale into specific color
While using torch and matplotlib I was able to change the grayscale color #50 e.g. to red. However, only by saving the image inbetween.
How can it be solved without saving the image?
I am sorry for the simple question, but I am new wit... | https://stackoverflow.com/questions/79366420/turn-grayscale-mask-image-into-rgb-while-changing-one-grayscale-into-specific-co | python, matplotlib, pytorch, torchvision | 1,737,162,516 |
se_78008233 | stackoverflow | MACHINE_LEARNING | Why KL divergence is negative in Pytorch? | Why KL divergence is negative in Pytorch?
I'm trying to get the KL divergence between 2 distributions using Pytorch, but the output is often negative which shouldn't be the case:
import torch
import torch.nn.functional as F
x_axis_kl_div_values = []
for epoch in range(200):
# each epoch generates 2 different dis... | https://stackoverflow.com/questions/78008233/why-kl-divergence-is-negative-in-pytorch | machine-learning, pytorch, loss-function | 1,708,095,527 |
se_79367203 | stackoverflow | MACHINE_LEARNING | Size Mismatch Error When Loading State Dict for TransformerDecoderModel | Size Mismatch Error When Loading State Dict for TransformerDecoderModel
I'm encountering an issue when trying to load a saved model state dictionary into my TransformerDecoderModel. The error I receive is:
RuntimeError: Error(s) in loading state_dict for TransformerDecoderModel:
size mismatch for embed.weight: cop... | https://stackoverflow.com/questions/79367203/size-mismatch-error-when-loading-state-dict-for-transformerdecodermodel | python, pytorch | 1,737,206,303 |
se_79364459 | stackoverflow | MACHINE_LEARNING | 100% accuracy for multi_class classification | 100% accuracy for multi_class classification
I am training a model for multi label classification task for each class I have multiple labels after running the test i got 100% for both classes
I used 150 000 images for training and validation and 30 000 image for the test and I am using the pretrained mobilenet_v2 mode... | https://stackoverflow.com/questions/79364459/100-accuracy-for-multi-class-classification | python, pytorch, conv-neural-network, loss-function, multiclass-classification | 1,737,109,986 |
se_79365805 | stackoverflow | MACHINE_LEARNING | Trying to use torch to optimize function parameters but loss remains same | Trying to use torch to optimize function parameters but loss remains same
I am trying to optimize the parameters of a function but the loss remains the same
class BoardOptimizer(torch.nn.Module):
def __init__(self):
super().__init__()
# Initialize parameters with current values but make them train... | https://stackoverflow.com/questions/79365805/trying-to-use-torch-to-optimize-function-parameters-but-loss-remains-same | python, pytorch | 1,737,138,996 |
se_79360980 | stackoverflow | MACHINE_LEARNING | What caused the large difference in execution time between these two forward passes? | What caused the large difference in execution time between these two forward passes?
for i in range(263):
states = torch.rand(128, 4, 20, 20, device = device)
# time.sleep(1)
start_time = time.time()
policy, value, action_value = model(states)
end_time = time.time()
tota... | https://stackoverflow.com/questions/79360980/what-caused-the-large-difference-in-execution-time-between-these-two-forward-pas | python, c++, deep-learning, pytorch, neural-network | 1,737,019,515 |
se_67248686 | stackoverflow | MACHINE_LEARNING | Neural network learning to sum two numbers | Neural network learning to sum two numbers
I am learning Pytorch, and I am trying to implement a really simple network which takes an input which is of length 2, i.e. a point in the plane, and aims to learn the sum of its components.
In principle the network should just learn a linear layer with weight matrix W = [1.,... | https://stackoverflow.com/questions/67248686/neural-network-learning-to-sum-two-numbers | deep-learning, neural-network, pytorch, linear-regression | 1,619,310,658 |
se_79358305 | stackoverflow | MACHINE_LEARNING | import Pytorch to create Neural Network. Running Error | import Pytorch to create Neural Network. Running Error
I'm using C++/Qt to run my Qt application.
Development Version:
Python: 3.12
Qt: 6.6.3
C++: std 17
Visual Studio 2022
Inside my code, I use Python/C API to run python script like:
PyObject* pModule = PyImport_ImportModule("DataModule");
if (pModule == nullpt... | https://stackoverflow.com/questions/79358305/import-pytorch-to-create-neural-network-running-error | c++, pytorch, neural-network, python-c-api | 1,736,945,939 |
se_79361940 | stackoverflow | MACHINE_LEARNING | Forward pass with all samples | Forward pass with all samples
import torch
import torch.nn as nn
class PINN(nn.Module):
def __init__(self, input_dim, output_dim, hidden_layers, neurons_per_layer):
super(PINN, self).__init__()
layers = []
layers.append(nn.Linear(input_dim, neurons_per_layer))
for _ in range(hidden... | https://stackoverflow.com/questions/79361940/forward-pass-with-all-samples | python, machine-learning, pytorch | 1,737,037,401 |
se_79356354 | stackoverflow | MACHINE_LEARNING | Pytorch: how to (efficiently) apply a function without a “dim” argument to each row of a 2D tensor? | Pytorch: how to (efficiently) apply a function without a “dim” argument to each row of a 2D tensor?
Long story short, I have a 2D matrix of ones and zeros and I need to retrieve, for each row, the indexes of the elements set to one. The “standard” way to do so would be torch.nonzero, but that function is well known fo... | https://stackoverflow.com/questions/79356354/pytorch-how-to-efficiently-apply-a-function-without-a-dim-argument-to-each | python, pytorch, tensor | 1,736,888,096 |
se_74979359 | stackoverflow | MACHINE_LEARNING | How is position wise feed forward neural network implemented for transformers? | How is position wise feed forward neural network implemented for transformers?
I am having hard time understanding position wise feed forward neural network in transformers architecture.
Lets take example as Machine translation task, where inputs are sentences. From the figure I understand that for each word, differe... | https://stackoverflow.com/questions/74979359/how-is-position-wise-feed-forward-neural-network-implemented-for-transformers | machine-learning, pytorch, neural-network, transformer-model | 1,672,639,165 |
se_69596496 | stackoverflow | MACHINE_LEARNING | (with cpu)Pytorch: IndexError: index out of range in self. (with cuda)Assertion `srcIndex < srcSelectDimSize` failed. How to solve? | (with cpu)Pytorch: IndexError: index out of range in self. (with cuda)Assertion `srcIndex < srcSelectDimSize` failed. How to solve?
Today I get the following error when I use BERT with Pytorch and cuda: /pytorch/aten/src/ATen/native/cuda/Indexing.cu:702: indexSelectLargeIndex: block: [234,0,0], thread: [0,0,0] Asse... | https://stackoverflow.com/questions/69596496/with-cpupytorch-indexerror-index-out-of-range-in-self-with-cudaassertion | python, machine-learning, nlp, pytorch, bert-language-model | 1,634,394,516 |
se_79360229 | stackoverflow | MACHINE_LEARNING | override pytorch Dataset efficiently | override pytorch Dataset efficiently
I want to inherit the torch.utils.data.Dataset class to load my custom image dataset, let's say for a classification task. here is the example of official pytorch website in this link:
import os
import pandas as pd
from torchvision.io import read_image
class CustomImageDataset(Dat... | https://stackoverflow.com/questions/79360229/override-pytorch-dataset-efficiently | python, machine-learning, deep-learning, pytorch, dataset | 1,736,995,101 |
se_79267821 | stackoverflow | MACHINE_LEARNING | cmake cant find onnx runtime lib | cmake cant find onnx runtime lib
Here is myCMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(TesteVoxarApp LANGUAGES CXX)
find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets LinguistTools)
find_path(ONNX_RUNTIME_SESSION_INCLUDE_DIRS REQUIRED onnxruntime_cxx_api.h HINTS "../../Documentos/onnxruntime-win-x... | https://stackoverflow.com/questions/79267821/cmake-cant-find-onnx-runtime-lib | qt, pytorch, onnx, onnxruntime | 1,733,825,289 |
se_79359767 | stackoverflow | MACHINE_LEARNING | Implementation of F1-score, IOU and Dice Score | Implementation of F1-score, IOU and Dice Score
This paper proposes a medical image segmentation hybrid CNN - Transformer model for segmenting organs and lesions in medical images simultaneously. Their model has two output branches, one to output organ mask, and the other to output lesion mask. Now they describe the te... | https://stackoverflow.com/questions/79359767/implementation-of-f1-score-iou-and-dice-score | python, machine-learning, deep-learning, pytorch, image-segmentation | 1,736,976,829 |
se_79343187 | stackoverflow | MACHINE_LEARNING | Implementation for a recursive computation in python | Implementation for a recursive computation in python
I'm trying to implement the recursion below for tilde_alpha_t:
I have torch tensors for t (time) which looks like this
t
tensor([816, 724, 295, 54, 205, 373, 665, 656, 690, 280, 234, 155, 31, 684,
159, 749, 893, 795, 375, 443, 121, 881, 477, 326, 337, 970... | https://stackoverflow.com/questions/79343187/implementation-for-a-recursive-computation-in-python | python, pytorch | 1,736,436,754 |
se_60949936 | stackoverflow | MACHINE_LEARNING | Why bilinear scaling of images with PIL and pytorch produces different results? | Why bilinear scaling of images with PIL and pytorch produces different results?
In order to feed an image to the pytorch network I first need to downscale it to some fixed size. At first I've done it using PIL.Image.resize() method, with interpolation mode set to BILINEAR. Then I though it would be more convenient to ... | https://stackoverflow.com/questions/60949936/why-bilinear-scaling-of-images-with-pil-and-pytorch-produces-different-results | python, image-processing, pytorch, python-imaging-library | 1,585,655,512 |
se_71433507 | stackoverflow | MACHINE_LEARNING | Pytorch Python Distributed Multiprocessing: Gather/Concatenate tensor arrays of different lengths/sizes | Pytorch Python Distributed Multiprocessing: Gather/Concatenate tensor arrays of different lengths/sizes
If you have tensor arrays of different lengths across several gpu ranks, the default all_gather method does not work as it requires the lengths to be same.
For example, if you have:
if gpu == 0:
q = torch.tensor... | https://stackoverflow.com/questions/71433507/pytorch-python-distributed-multiprocessing-gather-concatenate-tensor-arrays-of | python, pytorch, multiprocessing, concatenation, distributed | 1,646,971,366 |
se_79358379 | stackoverflow | MACHINE_LEARNING | CUDA not available | CUDA not available
I am aware variations of this have been asked multiple times, but even after working through many of those, I'm still stuck. I'm trying to get pytorch with CUDA support running on my Laptop. However, torch.cuda.is_available() returns False. Selected system information and diagnostic outputs are as f... | https://stackoverflow.com/questions/79358379/cuda-not-available | pytorch, cuda | 1,736,947,092 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.