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_72268859 | stackoverflow | MACHINE_LEARNING | Externally add a Variable to a model in TensorFlow | 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 list of parameters / computational graph.
One approach that I tried, is to append... | https://stackoverflow.com/questions/72268859/externally-add-a-variable-to-a-model-in-tensorflow | python, tensorflow, deep-learning, neural-network, pytorch | 1,652,767,207 |
se_79795624 | stackoverflow | MACHINE_LEARNING | Torch example transformer with TransformerDecoder | Torch example transformer with TransformerDecoder
In the torch example provided here https://github.com/pytorch/examples/tree/main/word_language_model, tansformer only uses torch.TransformerEncoder and torch.TransformerDecoder is overwritten with a simple Linear layer. I wanted to implement torch's Decoder in my code ... | https://stackoverflow.com/questions/79795624/torch-example-transformer-with-transformerdecoder | pytorch, nlp, large-language-model, transformer-model | 1,761,036,534 |
se_79795253 | stackoverflow | MACHINE_LEARNING | T5-small generates only padding tokens during validation/test in PyTorch Lightning | T5-small generates only padding tokens during validation/test in PyTorch Lightning
I'm fine-tuning T5-small using PyTorch Lightning and encountering a strange issue during validation and test steps.
The Problem:
During validation_step and test_step, model.generate() consistently produces batches of only padding tokens... | https://stackoverflow.com/questions/79795253/t5-small-generates-only-padding-tokens-during-validation-test-in-pytorch-lightni | pytorch, nlp, huggingface-transformers, pytorch-lightning, seq2seq | 1,760,991,078 |
se_79787781 | stackoverflow | MACHINE_LEARNING | Matching PyTorch and ONNX outputs layer-wise for debugging inference drift | Matching PyTorch and ONNX outputs layer-wise for debugging inference drift
I want to debug layer-by-layer to see where the ONNX model starts deviating from the PyTorch model outputs.
I can extract intermediate outputs in PyTorch using forward hooks, like:
def get_activation(name):
def hook(model, input, output):
... | https://stackoverflow.com/questions/79787781/matching-pytorch-and-onnx-outputs-layer-wise-for-debugging-inference-drift | machine-learning, pytorch, artificial-intelligence, onnx | 1,760,149,969 |
se_79794971 | stackoverflow | MACHINE_LEARNING | Fast vectorized maximal independent set greedy algorithm | Fast vectorized maximal independent set greedy algorithm
I need a really fast vectorized maximal independent set algorithm implemented in pytorch, so I can use it for tasks with thousands of nodes in reasonable time.
I cannot use networkx, it is way too slow for my needs.
I don't need an exact algorithm, a rough greed... | https://stackoverflow.com/questions/79794971/fast-vectorized-maximal-independent-set-greedy-algorithm | python, algorithm, pytorch | 1,760,968,718 |
se_73443382 | stackoverflow | MACHINE_LEARNING | AttributeError: module 'dill' has no attribute 'extend' | AttributeError: module 'dill' has no attribute 'extend'
I have just installed Pytorch, using:
(base) C:\>pip3 install torch torchvision torchaudio
Requirement already satisfied: torch in c:\users\Emil\appdata\roaming\python\python38\site-packages (1.9.0)
Requirement already satisfied: torchvision in c:... | https://stackoverflow.com/questions/73443382/attributeerror-module-dill-has-no-attribute-extend | python, pytorch, attributeerror, dill | 1,661,162,746 |
se_79788392 | stackoverflow | MACHINE_LEARNING | Torch Conv2d results in both dimensions convolved | Torch Conv2d results in both dimensions convolved
I have input shape to a convolution (50, 1, 7617, 10). Here, 7617 is word vectors as rows, and 10 is the number of words in columns. I want to convolve column-wise and obtain (2631, 1, 7617, 1), 1 sentence vector obtained by convolving all word vectors through a series... | https://stackoverflow.com/questions/79788392/torch-conv2d-results-in-both-dimensions-convolved | deep-learning, pytorch, neural-network, conv-neural-network, convolution | 1,760,247,295 |
se_79777399 | stackoverflow | MACHINE_LEARNING | Preventing GPU memory leak due to a custom neural network layer | Preventing GPU memory leak due to a custom neural network layer
I am using the MixStyle methodology for domain adaptation, and it involves using a custom layer that is inserted after every encoder stage. However, it is causing VRAM to grow linearly, which causes an OOM error.
No memory leak occurs on disabling the lay... | https://stackoverflow.com/questions/79777399/preventing-gpu-memory-leak-due-to-a-custom-neural-network-layer | deep-learning, pytorch, neural-network, computer-vision, semantic-segmentation | 1,759,071,642 |
se_79790378 | stackoverflow | MACHINE_LEARNING | How to lazy load jsonl file | How to lazy load jsonl file
I am trying to build a pytorch Dataset based on some .jsonl files. The size of each .jsonl file is about 2GB, and I have 50 such files. Therefore, it would be not very practical to load all these files into RAM. So, I am trying to use lazy loading. Currently, my implementation is as follows... | https://stackoverflow.com/questions/79790378/how-to-lazy-load-jsonl-file | python, json, pytorch, dataset, out-of-memory | 1,760,457,776 |
se_76633368 | stackoverflow | MACHINE_LEARNING | How does one set the pad token correctly (not to eos) during fine-tuning to avoid model not predicting EOS? | How does one set the pad token correctly (not to eos) during fine-tuning to avoid model not predicting EOS?
tldr; what I really want to know is what is the official way to set pad token for fine tuning it wasn't set during original training, so that it doesn't not learn to predict EOS.
colab: https://colab.research.go... | https://stackoverflow.com/questions/76633368/how-does-one-set-the-pad-token-correctly-not-to-eos-during-fine-tuning-to-avoi | machine-learning, pytorch, huggingface-transformers, huggingface, huggingface-tokenizers | 1,688,692,284 |
se_60018578 | stackoverflow | MACHINE_LEARNING | What does model.eval() do in pytorch? | What does model.eval() do in pytorch?
When should I use .eval()? I understand it is supposed to allow me to "evaluate my model". How do I turn it back off for training?
Example training code using .eval(). | https://stackoverflow.com/questions/60018578/what-does-model-eval-do-in-pytorch | python, machine-learning, deep-learning, pytorch | 1,580,572,695 |
se_74228361 | stackoverflow | MACHINE_LEARNING | Tokenizer can add padding without error, but data collator cannot | Tokenizer can add padding without error, but data collator cannot
I'm trying to fine tune a GPT2-based model on my data using the run_clm.py example script from HuggingFace.
I have a .json data file that looks like this:
...
{"text": "some text"}
{"text": "more text"}
...
I had to change the default behavior of the s... | https://stackoverflow.com/questions/74228361/tokenizer-can-add-padding-without-error-but-data-collator-cannot | pytorch, huggingface-transformers | 1,666,905,074 |
se_79692974 | stackoverflow | MACHINE_LEARNING | UndefinedErrorException in HostFunction:No implementation found for com.facebook.jni.HybridData org.pytorch.executorch.HuggingFaceTokenizer.initHybrid | UndefinedErrorException in HostFunction:No implementation found for com.facebook.jni.HybridData org.pytorch.executorch.HuggingFaceTokenizer.initHybrid
I am working with react-native-executorch and trying to use the models as mentioned in the documentation only.
const model = useTextEmbeddings({
modelSource: ALL_MI... | https://stackoverflow.com/questions/79692974/undefinederrorexception-in-hostfunctionno-implementation-found-for-com-facebook | react-native, machine-learning, pytorch | 1,751,897,311 |
se_69314108 | stackoverflow | MACHINE_LEARNING | How can I do a masked mean in PyTorch? | How can I do a masked mean in PyTorch?
This is the forward pass of a bidirectional RNN where I want to take the average pool of the output features. As you can see, I'm trying to exclude the time steps with a pad token from the calculation.
def forward(self, text):
# 'text' is shape (B, L)
embed = self.embed(t... | https://stackoverflow.com/questions/69314108/how-can-i-do-a-masked-mean-in-pytorch | pytorch | 1,632,482,140 |
se_79781054 | stackoverflow | MACHINE_LEARNING | Multimodal embedding requires video first, then image - why? | Multimodal embedding requires video first, then image - why?
I am working with OmniEmbed model (https://huggingface.co/Tevatron/OmniEmbed-v0.1), which is built on Qwen2.5 7B. My goal is to get a multimodal embedding for images and videos. I have the following code, which is basically the example code from the model ca... | https://stackoverflow.com/questions/79781054/multimodal-embedding-requires-video-first-then-image-why | python, pytorch, huggingface-transformers, embedding, multimodal | 1,759,417,659 |
se_79784709 | stackoverflow | MACHINE_LEARNING | Why does a LSTM pytorch model yield constant values? | Why does a LSTM pytorch model yield constant values?
I am training a LSTM model with data from yfinance. The process is really standard. I get the data with yf.download(ticker=ticker) where ticker='AAPL and do df.rolling(30, min_periods=1) to smooth the data. Then I adapt the data for training like this:
def create_ds... | https://stackoverflow.com/questions/79784709/why-does-a-lstm-pytorch-model-yield-constant-values | python, machine-learning, pytorch, neural-network, lstm | 1,759,850,970 |
se_79782616 | stackoverflow | MACHINE_LEARNING | TypeError: layer_norm(): argument 'input' (position 1) must be Tensor, not BaseModelOutput | TypeError: layer_norm(): argument 'input' (position 1) must be Tensor, not BaseModelOutput
I've got a problem:
TypeError: layer_norm(): argument 'input' (position 1) must be Tensor, not BaseModelOutput
when trying to put a batch of pictures into the ViT base model. The thing is that before giving it to the mo... | https://stackoverflow.com/questions/79782616/typeerror-layer-norm-argument-input-position-1-must-be-tensor-not-basem | python, pytorch, kaggle | 1,759,603,811 |
se_79710042 | stackoverflow | MACHINE_LEARNING | Convert custom YOLOX model (.pth) to tflite model and quantize model | Convert custom YOLOX model (.pth) to tflite model and quantize model
I have trained YOLOX using this repo on a custom dataset with 8 classes. The final output is a .pth file which I need to convert to a quantized .tflite format but I am completely stuck.
What I tried so far:
Use ai-edge-torch but I can't install the ... | https://stackoverflow.com/questions/79710042/convert-custom-yolox-model-pth-to-tflite-model-and-quantize-model | python, tensorflow, machine-learning, pytorch, tflite | 1,753,168,012 |
se_79785324 | stackoverflow | MACHINE_LEARNING | Required support for Detectron2 to ONNX conversion | Required support for Detectron2 to ONNX conversion
Currently I am working on Object Detection model. I have trained a model, want to convert to ONNX format for real time inference and deploy in the field but I am unable to determine how to convert to onnx format. I have tried converting to onnx format and detect objec... | https://stackoverflow.com/questions/79785324/required-support-for-detectron2-to-onnx-conversion | object, pytorch, detection, onnx, inference | 1,759,918,064 |
se_74122187 | stackoverflow | MACHINE_LEARNING | Detectron 2 to Onnx | Detectron 2 to Onnx
I want to convert a model into onnx
But when I import caffe2_export for exporting model to onnx I get this error
from detectron2.export import caffe2_export
ERROR
import onnx.optimizer
ModuleNotFoundError: No module named 'onnx.optimizer' | https://stackoverflow.com/questions/74122187/detectron-2-to-onnx | python, pytorch, onnx, detectron | 1,666,168,156 |
se_68580717 | stackoverflow | MACHINE_LEARNING | How can I solve this issue? input must have 3 dimensions, got 4 | How can I solve this issue? input must have 3 dimensions, got 4
The Below is data which I passed to the Data Loader,
train_path='/content/drive/MyDrive/Dataset_manual_pytorch/train'
test_path='/content/drive/MyDrive/Dataset_manual_pytorch/test'
train = torchvision.datasets.ImageFolder(train_path,transform=transformat... | https://stackoverflow.com/questions/68580717/how-can-i-solve-this-issue-input-must-have-3-dimensions-got-4 | python-3.x, deep-learning, pytorch | 1,627,580,930 |
se_79784425 | stackoverflow | MACHINE_LEARNING | Struggling to run a ONNX model in rust | Struggling to run a ONNX model in rust
I'm trying to run a ONNX model, using the rust crate ort
The model I'm trying to use is braai/RMBG-1.4
Below is the code I'm using. Apologies in advance for the variable names
let mut model = Session::builder()?
.with_optimization_level(GraphOptimizationLevel::Level3)... | https://stackoverflow.com/questions/79784425/struggling-to-run-a-onnx-model-in-rust | rust, pytorch, onnx | 1,759,831,280 |
se_79784351 | stackoverflow | MACHINE_LEARNING | PyTorch + Optuna causes random segmentation fault inside TransformerEncoderLayer (PyTorch 2.6, CUDA 12) | PyTorch + Optuna causes random segmentation fault inside TransformerEncoderLayer (PyTorch 2.6, CUDA 12)
I'm running into a segmentation fault when training a Transformer model with PyTorch 2.6.0 and Optuna on CUDA (12.4).
The exact same code used to work fine the issue appeared only after using Optuna.
The crash happe... | https://stackoverflow.com/questions/79784351/pytorch-optuna-causes-random-segmentation-fault-inside-transformerencoderlayer | python, pytorch, attention-model, optuna | 1,759,826,366 |
se_79782765 | stackoverflow | MACHINE_LEARNING | Python 3.13 cuda Pytorch 2.8 support | Python 3.13 cuda Pytorch 2.8 support
I am trying to use Torch to find my GPU for machine learning/training.
Right now, my code is using the CPU for training, which will take a long time with the large amounts of data I have.
import torch
print(torch.cuda.is_available())
print(torch.cuda.get_device_name(0))
I'm using ... | https://stackoverflow.com/questions/79782765/python-3-13-cuda-pytorch-2-8-support | python, pip, pytorch | 1,759,633,444 |
se_78908437 | stackoverflow | MACHINE_LEARNING | import torchtext - OSError: [WinError 127] | import torchtext - OSError: [WinError 127]
I'm trying to run a Test.py with 'import torchtext' in it.
it throws this error:
Traceback (most recent call last): File
"C:\Users\anryu\pythonProject\Test.py", line 10, in <module>
import torchtext File "C:\Users\anryu\pythonProject\.venv\Lib\site-packages\torchte... | https://stackoverflow.com/questions/78908437/import-torchtext-oserror-winerror-127 | pytorch, torchtext | 1,724,486,005 |
se_79769471 | stackoverflow | MACHINE_LEARNING | TensorRT PWC-Net Causing 2.4km Trajectory Error in iSLAM - Original PyTorch Works Fine | TensorRT PWC-Net Causing 2.4km Trajectory Error in iSLAM - Original PyTorch Works Fine
Problem Statement
My iSLAM system works correctly with the original PyTorch PWC-Net but produces catastrophic trajectory errors (2.4km ATE RMSE) when I replace it with a TensorRT-converted version. The TensorRT engine runs successfu... | https://stackoverflow.com/questions/79769471/tensorrt-pwc-net-causing-2-4km-trajectory-error-in-islam-original-pytorch-work | machine-learning, pytorch, nvidia, opticalflow, tensorrt | 1,758,283,020 |
se_79203477 | stackoverflow | MACHINE_LEARNING | Pytorch in Azure Synapse causing problems | Pytorch in Azure Synapse causing problems
I have a notebook in Azure Synapse that is using these libraries
import pandas as pd
import numpy as np
from sqlalchemy import create_engine, text
import sqlalchemy as sa
from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClie... | https://stackoverflow.com/questions/79203477/pytorch-in-azure-synapse-causing-problems | tensorflow, pytorch, azure-synapse, torch | 1,732,020,344 |
se_79421423 | stackoverflow | MACHINE_LEARNING | How to fix Index put requires the source and destination dtypes match` with `google/gemma-2-2b` in Transformers? | How to fix Index put requires the source and destination dtypes match` with `google/gemma-2-2b` in Transformers?
I’m trying to train a language model using google/gemma-2-2b with the Hugging Face Transformers Trainer. The same training script works fine for other models like gpt2 and meta-llama/Meta-Llama-3-8B, but wi... | https://stackoverflow.com/questions/79421423/how-to-fix-index-put-requires-the-source-and-destination-dtypes-match-with-goo | pytorch, huggingface-transformers, huggingface, huggingface-trainer | 1,738,942,561 |
se_76674386 | stackoverflow | MACHINE_LEARNING | AttributeError: module 'tqdm' has no attribute 'auto' | AttributeError: module 'tqdm' has no attribute 'auto'
I am trying to run a git repo called Spacetimeformer and I am getting this error while training a program
lib\site-packages\torchmetrics\functional\text\bert.py", line 247, in <module>
AttributeError: module 'tqdm' has no attribute 'auto'
The code ... | https://stackoverflow.com/questions/76674386/attributeerror-module-tqdm-has-no-attribute-auto | python, pytorch, tqdm, pytorch-lightning | 1,689,195,251 |
se_61503720 | stackoverflow | MACHINE_LEARNING | Best practice to pass PyTorch device name to model | Best practice to pass PyTorch device name to model
Currently, I separated train.py with model.py for my deep learning project.
So for the datasets, they are sent to cuda device inside the epoch for loop like below.
train.py
...
device = torch.device('cuda:2' if torch.cuda.is_available() else 'cpu')
model = MyNet(~... | https://stackoverflow.com/questions/61503720/best-practice-to-pass-pytorch-device-name-to-model | python, pytorch | 1,588,169,125 |
se_70555815 | stackoverflow | MACHINE_LEARNING | PyTorch Lightning training console output is weird | PyTorch Lightning training console output is weird
When training a PyTorch Lightning model in a Jupyter Notebook, the console log output is awkward:
Epoch 0: 100%|█████████▉| 2315/2318 [02:05<00:00, 18.41it/s, loss=1.69, v_num=26, acc=0.562]
Validating: 0it [00:00, ?it/s]
Validating: 0%| | 0/1 [00:00<?, ?it... | https://stackoverflow.com/questions/70555815/pytorch-lightning-training-console-output-is-weird | python, logging, jupyter-notebook, pytorch, pytorch-lightning | 1,641,125,198 |
se_79772854 | stackoverflow | MACHINE_LEARNING | import torch error: DLL load failed while importing _C | import torch error: DLL load failed while importing _C
I was trying to follow a project in university where we had to import cellpose. The import delivered an error message which could be tracebacked to import torch (see below). Every import was done in a clean pre-defined environment, which worked for most of the oth... | https://stackoverflow.com/questions/79772854/import-torch-error-dll-load-failed-while-importing-c | python, dll, pytorch, pycharm, torch | 1,758,644,830 |
se_74487220 | stackoverflow | MACHINE_LEARNING | Pytorch Batchwise block diagonal | Pytorch Batchwise block diagonal
I have two tensors containing batches of matrices of the same batch size (first dimension) but different matrix structure (all other dimensions).
For example A of shape (n,d,d) and B (n,e,e).
Now I would like to build block diagonals of A and B for all n.
So that the output shape (n,(d... | https://stackoverflow.com/questions/74487220/pytorch-batchwise-block-diagonal | python, pytorch, torch, diagonal | 1,668,762,356 |
se_79773172 | stackoverflow | MACHINE_LEARNING | pippy examples: torch._dynamo.exc.UserError: It looks like one of the outputs with type <class transformers.cache_utils.DynamicCache> is not supported | pippy examples: torch._dynamo.exc.UserError: It looks like one of the outputs with type <class transformers.cache_utils.DynamicCache> is not supported
when the program starts to initialize pipeline object, a unexpected error was thrown:
[rank0]: Traceback (most recent call last):
[rank0]: File "/root/anaconda3... | https://stackoverflow.com/questions/79773172/pippy-examples-torch-dynamo-exc-usererror-it-looks-like-one-of-the-outputs-wi | python, pytorch, huggingface-transformers, llama | 1,758,672,320 |
se_79771930 | stackoverflow | MACHINE_LEARNING | How to integrate a lightweight image-to-text model into a React Native app? | How to integrate a lightweight image-to-text model into a React Native app?
I am trying to integrate an image-to-text model into a React Native mobile app.
My requirements:
The model should support image + text input → text output.
It should be lightweight enough to run on mobile devices.
What I tried
moondream-0.5b (... | https://stackoverflow.com/questions/79771930/how-to-integrate-a-lightweight-image-to-text-model-into-a-react-native-app | react-native, machine-learning, pytorch, nlp, onnx | 1,758,564,305 |
se_57231943 | stackoverflow | MACHINE_LEARNING | How can I randomly shuffle the labels of a Pytorch Dataset? | How can I randomly shuffle the labels of a Pytorch Dataset?
I am new to Pytorch, and I am having troubles with some technicalities. I have downloaded the MNIST dataset, using the following command:
train_dataset = dsets.MNIST(root='./data',
train=True,
transfo... | https://stackoverflow.com/questions/57231943/how-can-i-randomly-shuffle-the-labels-of-a-pytorch-dataset | machine-learning, computer-vision, dataset, pytorch | 1,564,228,843 |
se_71075872 | stackoverflow | MACHINE_LEARNING | How to build pytorch from source? | How to build pytorch from source?
When I use PyTorch, it shows that the CUDA version used by PyTorch and the system CUDA version are inconsistent, so I need to rebuild PyTorch from source.
# Install dependency
pip install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six ... | https://stackoverflow.com/questions/71075872/how-to-build-pytorch-from-source | python, pytorch | 1,644,560,165 |
se_60796555 | stackoverflow | MACHINE_LEARNING | Certain members of a torch module aren't moved to GPU even if model.to(device) is called | Certain members of a torch module aren't moved to GPU even if model.to(device) is called
An mwe is as follows:
import torch
import torch.nn as nn
class model(nn.Module):
def __init__(self):
super(model,self).__init__()
self.mat = torch.randn(2,2)
def forward(self,x):
print('self.... | https://stackoverflow.com/questions/60796555/certain-members-of-a-torch-module-arent-moved-to-gpu-even-if-model-todevice-i | python, pytorch | 1,584,858,568 |
se_79710660 | stackoverflow | MACHINE_LEARNING | Can't prepare Pytorch environment in ML Studio | Can't prepare Pytorch environment in ML Studio
My model worked in notebooks, where I just pip installed the required packages. But I am trying to run on a pipeline, and when I submit the pipeline as a job I get stuck in the Preparing phase. I believe this is due to the environment not resolving correctly. I've att... | https://stackoverflow.com/questions/79710660/cant-prepare-pytorch-environment-in-ml-studio | python, pytorch, azure-machine-learning-service, azure-ml-pipelines | 1,753,195,565 |
se_76302971 | stackoverflow | MACHINE_LEARNING | AttributeError: 'NoneType' object has no attribute 'Lock' (Pytorch transformer_tutorial) | AttributeError: 'NoneType' object has no attribute 'Lock' (Pytorch transformer_tutorial)
When I run the transformer_tutorial code from Pytorch (https://pytorch.org/tutorials/beginner/transformer_tutorial.html), I meet a problem in build_vocab_from_iterator.
from torchtext.datasets import WikiText2
from... | https://stackoverflow.com/questions/76302971/attributeerror-nonetype-object-has-no-attribute-lock-pytorch-transformer-t | python, pytorch, attributeerror, torchtext | 1,684,728,240 |
se_75710776 | stackoverflow | MACHINE_LEARNING | Huggingface GPT2 loss understanding | Huggingface GPT2 loss understanding
(Also posted here https://discuss.huggingface.co/t/newbie-understanding-gpt2-loss/33590)
I am getting stuck with understanding the GPT2 loss. I want to give the model the label having the target it will generate so that I can see that loss is zero.
I have a input text
input_text =... | https://stackoverflow.com/questions/75710776/huggingface-gpt2-loss-understanding | pytorch, huggingface-transformers, gpt-2 | 1,678,588,447 |
se_69530476 | stackoverflow | MACHINE_LEARNING | How to use soft labels in computer vision with PyTorch? | How to use soft labels in computer vision with PyTorch?
I have an image dataset with soft labels (i.e. the images don't belong to a single class, but rather I have a probability distribution saying that there's a 66% chance this image belong in one class and 33% chance it belongs in some other class).
I am struggling ... | https://stackoverflow.com/questions/69530476/how-to-use-soft-labels-in-computer-vision-with-pytorch | machine-learning, pytorch, neural-network, computer-vision, classification | 1,633,974,485 |
se_79764717 | stackoverflow | MACHINE_LEARNING | Why does hugging face trainer still recognize different device between my encoder & classifier head even after I manually map it on the same device | Why does hugging face trainer still recognize different device between my encoder & classifier head even after I manually map it on the same device
I encounterd this error while trying to run hugging face trainer on a multi-gpu.
RuntimeError: Expected all tensors to be on the same device, but found at least two de... | https://stackoverflow.com/questions/79764717/why-does-hugging-face-trainer-still-recognize-different-device-between-my-encode | pytorch, large-language-model, huggingface, multi-gpu, huggingface-trainer | 1,757,907,918 |
se_79756836 | stackoverflow | MACHINE_LEARNING | Open source AI: How can I use uv or pip to install the *correct* build of PyTorch (CUDA, CPU, ROCm, etc.)? | Open source AI: How can I use uv or pip to install the *correct* build of PyTorch (CUDA, CPU, ROCm, etc.)?
My project uses PyTorch and Lightning. Since PyTorch is system dependent, users need to install it manually, based on their platform, using the platform-specific pip command provided by the PyTorch site. We use u... | https://stackoverflow.com/questions/79756836/open-source-ai-how-can-i-use-uv-or-pip-to-install-the-correct-build-of-pytorc | pytorch, dependencies, portability, pytorch-lightning, uv | 1,757,079,043 |
se_79764662 | stackoverflow | MACHINE_LEARNING | Pytorch on Import torchrl.data: AttributeError: __provides__. Did you mean: '__providedBy__'? | Pytorch on Import torchrl.data: AttributeError: __provides__. Did you mean: '__providedBy__'?
I’m new at this and I’m trying to dabble in Pytorch and PytorchRL. However, as the topic states, before I can even load up the model, I get that AtrributeError message. This is the full error message I get:
Traceback ... | https://stackoverflow.com/questions/79764662/pytorch-on-import-torchrl-data-attributeerror-provides-did-you-mean-p | pytorch, reinforcement-learning | 1,757,898,377 |
se_67821588 | stackoverflow | MACHINE_LEARNING | Is it possible to run multiple CUDA version on windows? | Is it possible to run multiple CUDA version on windows?
I am doing an experiment on a chest x-ray Project. and I want multiple versions of the CUDA toolkit but the problem is that my system put the latest version which I installed lastly is appearing.
Is it possible to run any of CUDA like 9.0, 10.2, 11.0 as required ... | https://stackoverflow.com/questions/67821588/is-it-possible-to-run-multiple-cuda-version-on-windows | cuda, pytorch, nvidia, torchvision | 1,622,723,730 |
se_77737679 | stackoverflow | MACHINE_LEARNING | Create a multilingual chatbot | Create a multilingual chatbot
I created a chatbot using PyTorch an I want to make it support the French language. Note that I want to train the chatbot so that it can respond to technical questions.
One of the things that came to my mind is to use translation APIs but since the chatbot is expected to respond to techni... | https://stackoverflow.com/questions/77737679/create-a-multilingual-chatbot | python, machine-learning, pytorch, nlp, chatbot | 1,703,977,527 |
se_79064600 | stackoverflow | MACHINE_LEARNING | learning rate in torch.optim.AdamW has no effect? | learning rate in torch.optim.AdamW has no effect?
I am working on fine-tuning BLIP-2 on the RSICD dataset using LoRA. I am working on colab, using an A100. I am strangely finding that when I set the learning rate in the code below, it has no effect. I can set it to 10^55, or I can set it to 10^(-55), and the loss stil... | https://stackoverflow.com/questions/79064600/learning-rate-in-torch-optim-adamw-has-no-effect | pytorch, scheduler, learning-rate | 1,728,368,923 |
se_79740028 | stackoverflow | MACHINE_LEARNING | Freeze, then unfreeze gradients of a trained parameter in PyTorch does not work | Freeze, then unfreeze gradients of a trained parameter in PyTorch does not work
Let's say I have a parameter which is a p-shaped vector and I wish to train it in PyTorch such that: for some iterations, only the first k <= p elements of this vector were trained whereas the rest were frozen; for some other iterations, t... | https://stackoverflow.com/questions/79740028/freeze-then-unfreeze-gradients-of-a-trained-parameter-in-pytorch-does-not-work | python, machine-learning, pytorch, gradient-descent | 1,755,612,558 |
se_78519823 | stackoverflow | MACHINE_LEARNING | (Windows) No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8' | (Windows) No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8'
I am trying to setup gaussian splatting with conda, however when it comes to installing the submodules - diff-gaussian-rasterization & simple-knn, it reports the error "No CUDA runtime is found, using... | https://stackoverflow.com/questions/78519823/windows-no-cuda-runtime-is-found-using-cuda-home-c-program-files-nvidia-gpu | pytorch, cuda, runtime, nvidia, system-variable | 1,716,409,029 |
se_79761576 | stackoverflow | MACHINE_LEARNING | mlflow unable to generate input output schema when using log_model() | mlflow unable to generate input output schema when using log_model()
I am using the latest mlflow 3.3.2 with a simple PyTorch implementation of SRCNN. I am able to log the parameters as well as the metrics for the training process as well as generate custom visualizations for the losses and PSNR alongside the model wi... | https://stackoverflow.com/questions/79761576/mlflow-unable-to-generate-input-output-schema-when-using-log-model | python, pytorch, mlflow | 1,757,574,883 |
se_68796654 | stackoverflow | MACHINE_LEARNING | ValueError: x_max is less than or equal to x_min for bbox | ValueError: x_max is less than or equal to x_min for bbox
I am using albumentations for a set of images and bboxes.
My bounding box is in "yolo" format, i.e., (x_mid, y_mid, width, height), all normalised.
While running albumentations for a set of bounding errors, above error comes (ValueError: x_max is less than or e... | https://stackoverflow.com/questions/68796654/valueerror-x-max-is-less-than-or-equal-to-x-min-for-bbox | python, pytorch, bounding-box, image-augmentation, albumentations | 1,629,078,956 |
se_79758894 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError for transformers.pipeline after installing PyTorch for CUDA | ModuleNotFoundError for transformers.pipeline after installing PyTorch for CUDA
I'm a bit stumped on an issue that just popped up. My code, which uses the transformers library, was running perfectly fine until I tried to install a CUDA-compatible version of PyTorch.
Everything broke right after I ran this command to g... | https://stackoverflow.com/questions/79758894/modulenotfounderror-for-transformers-pipeline-after-installing-pytorch-for-cuda | python, pytorch, huggingface-transformers | 1,757,335,667 |
se_79367182 | stackoverflow | MACHINE_LEARNING | ImportError: cannot import name 'Tensor' from 'torch' (unknown location) | ImportError: cannot import name 'Tensor' from 'torch' (unknown location)
I’m trying to import Tensor from PyTorch:
from torch import Tensor
but I keep getting this error:
ImportError: cannot import name 'Tensor' from 'torch' (unknown location)
What I’ve Tried:
Checked that PyTorch is installed (pip ... | https://stackoverflow.com/questions/79367182/importerror-cannot-import-name-tensor-from-torch-unknown-location | python, machine-learning, pytorch | 1,737,205,475 |
se_71473217 | stackoverflow | MACHINE_LEARNING | Pytorch show source of/handle CUDA warnings for deallocation and tensor release | Pytorch show source of/handle CUDA warnings for deallocation and tensor release
I am running some parallel workers using Pytorch, CUDA, and torch.multiprocessing (torch.mp), with info being passed around with torch.mp Queues, Pipes, and shared_memory as appropriate. Everything appears to work, but I occasionally get a... | https://stackoverflow.com/questions/71473217/pytorch-show-source-of-handle-cuda-warnings-for-deallocation-and-tensor-release | python, pytorch, warnings | 1,647,286,016 |
se_69367939 | stackoverflow | MACHINE_LEARNING | Understanding backpropagation in PyTorch | Understanding backpropagation in PyTorch
I am exploring PyTorch, and I do not understand the output of the following example:
# Initialize x, y and z to values 4, -3 and 5
x = torch.tensor(4., requires_grad = True)
y = torch.tensor(-3., requires_grad = True)
z = torch.tensor(5., requires_grad = True)
# Set q to sum ... | https://stackoverflow.com/questions/69367939/understanding-backpropagation-in-pytorch | python, deep-learning, neural-network, pytorch, backpropagation | 1,632,859,822 |
se_79757417 | stackoverflow | MACHINE_LEARNING | How can I empty the GPU memory when I get a error like OOM? | How can I empty the GPU memory when I get a error like OOM?
sometimes,when I got a OOM error,but the parameters of LLM has been load in GPU,and it cannot be cleared automatically.
So,I try this
torch.cuda.empty_cache()
but it did't work.So,everytime I must restart my GPU to clear the cache. | https://stackoverflow.com/questions/79757417/how-can-i-empty-the-gpu-memory-when-i-get-a-error-like-oom | python, pytorch, gpu | 1,757,146,409 |
se_76900349 | stackoverflow | MACHINE_LEARNING | Repo id error when using hugging face transformers | Repo id error when using hugging face transformers
I keep getting this error when I try to use hugging face transformers library.
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': 'C:/Users/FZH91R/PycharmProjects/DudeWheresMyHealing/Pytorch/tf_model.... | https://stackoverflow.com/questions/76900349/repo-id-error-when-using-hugging-face-transformers | python, machine-learning, pytorch, huggingface-transformers, huggingface-tokenizers | 1,692,027,634 |
se_72959030 | stackoverflow | MACHINE_LEARNING | How does the queue in Pytorch DataLoader work with num_workers >= 2? | How does the queue in Pytorch DataLoader work with num_workers >= 2?
Do I understand the following correctly?
When num_workers >=1, the main process pre-loads prefetch_factor * num_workers batches. When the training loop consumes one batch, the corresponding worker loads the next batch in its queue.
If this is the ... | https://stackoverflow.com/questions/72959030/how-does-the-queue-in-pytorch-dataloader-work-with-num-workers-2 | python, pytorch, pytorch-dataloader | 1,657,664,982 |
se_79756909 | stackoverflow | MACHINE_LEARNING | Error while converting quantized Torch model to ONNX | Error while converting quantized Torch model to ONNX
I’m applying QAT to YOLOv8n model with the following configuration:
QConfig(
activation=FakeQuantize.with_args(
observer=MovingAverageMinMaxObserver,
quant_min=0,
quant_max=255,
dtype=torch.quint8,
qscheme=torch.per_tensor... | https://stackoverflow.com/questions/79756909/error-while-converting-quantized-torch-model-to-onnx | pytorch, quantization, yolov8, quantization-aware-training | 1,757,083,141 |
se_67600035 | stackoverflow | MACHINE_LEARNING | _pygit2.GitError: Repository not found at | _pygit2.GitError: Repository not found at
def save_experiment_config(self):
with open(os.path.join(self.experiment_dir, 'parameters.txt'), 'w') as file:
config_dict = vars(self.args)
for k in vars(self.args):
file.write(f"{k}={config_dict[k]} \n")
repo = Repository('.')
... | https://stackoverflow.com/questions/67600035/pygit2-giterror-repository-not-found-at | pytorch, repository | 1,621,414,710 |
se_79754439 | stackoverflow | MACHINE_LEARNING | ValueError when resuming LoRA fine-tuning with sentence-transformers CrossEncoderTrainer: "Unrecognized model" error | ValueError when resuming LoRA fine-tuning with sentence-transformers CrossEncoderTrainer: "Unrecognized model" error
I'm fine-tuning a CrossEncoder model with LoRA using sentence-transformers library on Kaggle (12-hour limit). I need to resume training from a checkpoint, but I'm getting a ValueError when try... | https://stackoverflow.com/questions/79754439/valueerror-when-resuming-lora-fine-tuning-with-sentence-transformers-crossencode | pytorch, huggingface-transformers, sentence-transformers, peft | 1,756,894,205 |
se_79754732 | stackoverflow | MACHINE_LEARNING | Why my Transformer model did not work well when dealing with single cell multi-omic data | Why my Transformer model did not work well when dealing with single cell multi-omic data
The complete codes and data are available at:Google Disk
I'm working on a high-dimensional regression problem and have built a Transformer-based model in PyTorch. While the model trains, I'm observing a strange behavior: the valid... | https://stackoverflow.com/questions/79754732/why-my-transformer-model-did-not-work-well-when-dealing-with-single-cell-multi-o | python, pytorch, data-analysis, bioinformatics, transformer-model | 1,756,909,861 |
se_79754246 | stackoverflow | MACHINE_LEARNING | Rotation with Pytorch Torchvision but from two specific angles | Rotation with Pytorch Torchvision but from two specific angles
I want to randomly rotate my images at 45 degrees or -45 degrees, but only these two, no in between. 50% chances for 45 and 50% for -45.
I know that I can use RandomRotation of torchvision, but if I do like in this example:
import torchvision.transforms as... | https://stackoverflow.com/questions/79754246/rotation-with-pytorch-torchvision-but-from-two-specific-angles | python, pytorch, torchvision, data-augmentation | 1,756,883,434 |
se_79751915 | stackoverflow | MACHINE_LEARNING | PyTorch XPU training loop memory leak despite explicit cleanup (gc.collect, torch.xpu.empty_cache) | PyTorch XPU training loop memory leak despite explicit cleanup (gc.collect, torch.xpu.empty_cache)
I’m training a RVC which use HIFI-GAN-style speech model on Intel XPU (PyTorch 2.3, oneAPI backend). During training, my GPU/XPU memory usage keeps growing with each batch until OOM, even though I explicitly delete tenso... | https://stackoverflow.com/questions/79751915/pytorch-xpu-training-loop-memory-leak-despite-explicit-cleanup-gc-collect-torc | machine-learning, deep-learning, pytorch | 1,756,660,623 |
se_65332165 | stackoverflow | MACHINE_LEARNING | Loss is “nan” when fine-tuning HuggingFace NLI model (both RoBERTa/BART) | Loss is “nan” when fine-tuning HuggingFace NLI model (both RoBERTa/BART)
I'm using HuggingFace's Transformer's library and I’m trying to fine-tune a pre-trained NLI model (ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli) on a dataset of around 276.000 hypothesis-premise pairs. I’m following the instructions from ... | https://stackoverflow.com/questions/65332165/loss-is-nan-when-fine-tuning-huggingface-nli-model-both-roberta-bart | python, nlp, pytorch, huggingface-transformers, huggingface-tokenizers | 1,608,158,492 |
se_79049542 | stackoverflow | MACHINE_LEARNING | Pytorch import stuck on torch_version | Pytorch import stuck on torch_version
I am currently starting to do basic Machine Learning via Pytorch on Linux Mint. However, I have this very weird issue. I have some imports, normally they only take at most 10s to run, and I can go on doing my things. However, today, I run the exact same code, and now, importing su... | https://stackoverflow.com/questions/79049542/pytorch-import-stuck-on-torch-version | python, visual-studio-code, jupyter-notebook, pytorch | 1,727,940,942 |
se_79751502 | stackoverflow | MACHINE_LEARNING | When does non-blocking H2D copy from pinned memory in pytorch require synchronization? | When does non-blocking H2D copy from pinned memory in pytorch require synchronization?
According to PyTorch tutorial,
Until now, we have operated under the assumption that asynchronous copies from the CPU to the GPU are safe. This is generally true because CUDA automatically handles synchronization to ensure that the... | https://stackoverflow.com/questions/79751502/when-does-non-blocking-h2d-copy-from-pinned-memory-in-pytorch-require-synchroniz | pytorch | 1,756,599,058 |
se_50675219 | stackoverflow | MACHINE_LEARNING | Google Colab: "Unable to connect to the runtime" after uploading Pytorch model from local | Google Colab: "Unable to connect to the runtime" after uploading Pytorch model from local
I am using a simple (not necessarily efficient) method for Pytorch model saving.
import torch
from google.colab import files
torch.save(model, filename) # save a trained model on the VM
files.download(filename) # do... | https://stackoverflow.com/questions/50675219/google-colab-unable-to-connect-to-the-runtime-after-uploading-pytorch-model-f | pytorch, google-colaboratory, data-persistence | 1,528,096,795 |
se_66979507 | stackoverflow | MACHINE_LEARNING | The best way to implement stateful LSTM/ConvLSTM in Pytorch? | The best way to implement stateful LSTM/ConvLSTM in Pytorch?
I am trying to boost the performance of a object detection task with sequential information, using ConvLSTM.
A typical ConvLSTM model takes a 5D tensor with shape (samples, time_steps, channels, rows, cols) as input.
as stated in this post, a long sequence o... | https://stackoverflow.com/questions/66979507/the-best-way-to-implement-stateful-lstm-convlstm-in-pytorch | python, pytorch, conv-neural-network, lstm, recurrent-neural-network | 1,617,769,163 |
se_76326776 | stackoverflow | MACHINE_LEARNING | Can't get hyperparameters to pass in as arguments to a sagemaker estimator when using a custom docker image | Can't get hyperparameters to pass in as arguments to a sagemaker estimator when using a custom docker image
I just need to pass hyperparameters to my training job when using a custom docker image
When I remove the custom image "image_uri" I can see the arguments being passed, but things don't work as I need the cu... | https://stackoverflow.com/questions/76326776/cant-get-hyperparameters-to-pass-in-as-arguments-to-a-sagemaker-estimator-when | python, docker, pytorch, amazon-sagemaker | 1,684,955,920 |
se_79750034 | stackoverflow | MACHINE_LEARNING | FSDP Mesh_dim_names in init_device_mesh not work | FSDP Mesh_dim_names in init_device_mesh not work
I use fsdp to init my model.
Here is my code:
device_mesh = init_device_mesh(
"cuda",
mesh_shape=(1, 8),
mesh_dim_names=("replicate","shard"),
)
model = FSDP(
model,
... | https://stackoverflow.com/questions/79750034/fsdp-mesh-dim-names-in-init-device-mesh-not-work | pytorch | 1,756,457,421 |
se_76808576 | stackoverflow | MACHINE_LEARNING | Pytorch tensorboard graph visualization error(TracingCheckError) | Pytorch tensorboard graph visualization error(TracingCheckError)
I'm encountering an error with the code below. What I'm trying to do is fairly simple: I want to visualize a PyTorch model using TensorBoard. I have absolutely no idea why this error is occurring.
import torch
from torch import nn
class MyModel(nn.Module... | https://stackoverflow.com/questions/76808576/pytorch-tensorboard-graph-visualization-errortracingcheckerror | pytorch, tensorboard | 1,690,865,134 |
se_79671934 | stackoverflow | MACHINE_LEARNING | ValueError: No valid stream found in input file. Is -1 of the desired media type? | ValueError: No valid stream found in input file. Is -1 of the desired media type?
While using torchcodec with the following code
import torchcodec
file_path = "/path/to/episode_000000.mp4"
x = torchcodec.decoders.VideoDecoder(file_path, seek_mode="approximate")
I got the following error:
[rank0]: File "/home/hzxie/... | https://stackoverflow.com/questions/79671934/valueerror-no-valid-stream-found-in-input-file-is-1-of-the-desired-media-type | python, ffmpeg, pytorch, torchcodec, lerobot | 1,750,329,725 |
se_78604979 | stackoverflow | MACHINE_LEARNING | how to train equivariant transformer on atomic coordinate data | how to train equivariant transformer on atomic coordinate data
i'm new to using transformers. i'm trying to use the equiformer model docs here to train a score function on atomic coordinate data. the atomic coordinate data is an Nx3 array, where N is the number of atoms and 3 because of 3 spatial dimensions. likewise,... | https://stackoverflow.com/questions/78604979/how-to-train-equivariant-transformer-on-atomic-coordinate-data | pytorch, transformer-model | 1,718,066,840 |
se_74593644 | stackoverflow | MACHINE_LEARNING | How to fix no token found error while downloading hugging face? | How to fix no token found error while downloading hugging face?
I am trying to test the hugging face's prithivida/parrot_paraphraser_on_T5 model but getting token not found error.
from parrot import Parrot
import torch
import warnings
warnings.filterwarnings("ignore")
parrot = Parrot(model_tag="prithivida/parrot_parap... | https://stackoverflow.com/questions/74593644/how-to-fix-no-token-found-error-while-downloading-hugging-face | python-3.x, pytorch, huggingface-transformers | 1,669,581,409 |
se_79742073 | stackoverflow | MACHINE_LEARNING | Export a PyTorch custom hash table lookup OP to ONNX | Export a PyTorch custom hash table lookup OP to ONNX
I have implemented a PyTorch OP which accepts a torch.int64 tensor and outputs another torch.int64 tensor by looking up a hash table with predefined key-value pairs.
The torch part is implemented like this, where table is a wrapper around a C++ hash table:
class Tab... | https://stackoverflow.com/questions/79742073/export-a-pytorch-custom-hash-table-lookup-op-to-onnx | python, pytorch, onnx | 1,755,767,209 |
se_78681145 | stackoverflow | MACHINE_LEARNING | PyTorch UserWarning: Failed to initialize NumPy: _ARRAY_API not found and BERTModel weight initialization issue | PyTorch UserWarning: Failed to initialize NumPy: _ARRAY_API not found and BERTModel weight initialization issue
I am working with PyTorch and the Hugging Face Transformers library to fine-tune a BERT model (UFNLP/gatortron-base) for a downstream task.
I received a warning related to NumPy initialization:
C:\Users\use... | https://stackoverflow.com/questions/78681145/pytorch-userwarning-failed-to-initialize-numpy-array-api-not-found-and-bertmo | python, numpy, pytorch | 1,719,559,501 |
se_79743002 | stackoverflow | MACHINE_LEARNING | How do I create a Pytorch Dataset from multiple files where each file has multiple batches | How do I create a Pytorch Dataset from multiple files where each file has multiple batches
How do I create an dataset that reads in data from multiple files, but where each file has lots of rows or batches.
For example, I have a partitioned parquet dataset (created with pandas.to_parquet), with text or embeddings in e... | https://stackoverflow.com/questions/79743002/how-do-i-create-a-pytorch-dataset-from-multiple-files-where-each-file-has-multip | python, machine-learning, pytorch, nlp | 1,755,840,923 |
se_79741908 | stackoverflow | MACHINE_LEARNING | Calculating the partial derivative of PyTorch model output with respect to neurons pre-activation | Calculating the partial derivative of PyTorch model output with respect to neurons pre-activation
I am working on neuron importance for ANNs (in a classification setting). A simple baseline is the partial derivative of the model output for the correct class with respect to the given neuron pre-activation. My goal is t... | https://stackoverflow.com/questions/79741908/calculating-the-partial-derivative-of-pytorch-model-output-with-respect-to-neuro | python, machine-learning, deep-learning, pytorch | 1,755,757,301 |
se_78128662 | stackoverflow | MACHINE_LEARNING | Converting Pytorch bfloat16 tensors to numpy throws TypeError | Converting Pytorch bfloat16 tensors to numpy throws TypeError
When you try to convert a Torch bfloat16 tensor to a numpy array, it throws a TypeError:
import torch
x = torch.Tensor([0]).to(torch.bfloat16)
x.numpy() # TypeError: Got unsupported ScalarType BFloat16
import numpy as np
np.array(x) # same error
Is the... | https://stackoverflow.com/questions/78128662/converting-pytorch-bfloat16-tensors-to-numpy-throws-typeerror | python, numpy, pytorch, floating-point, tensor | 1,709,911,122 |
se_63423463 | stackoverflow | MACHINE_LEARNING | Using pytorch Cuda on MacBook Pro | Using pytorch Cuda on MacBook Pro
I am using MacBook Pro (16-inch, 2019, macOS 10.15.5 (19F96))
GPU
AMD Radeon Pro 5300M
Intel UHD Graphics 630
I am trying to use Pytorch with Cuda on my mac.
All of the guides I saw assume that i have Nvidia graphic card.
I found this: https://github.com/pytorch/pytorch/issues/10657... | https://stackoverflow.com/questions/63423463/using-pytorch-cuda-on-macbook-pro | macos, pytorch | 1,597,474,817 |
se_50735493 | stackoverflow | MACHINE_LEARNING | How to share a list of tensors in PyTorch multiprocessing? | How to share a list of tensors in PyTorch multiprocessing?
I am programming with PyTorch multiprocessing. I want all the subprocesses can read/write the same list of tensors (no resize). For example the variable can be
m = list(torch.randn(3), torch.randn(5))
Because each tensor has different sizes, I cannot organi... | https://stackoverflow.com/questions/50735493/how-to-share-a-list-of-tensors-in-pytorch-multiprocessing | list, multiprocessing, sharing, pytorch, tensor | 1,528,357,129 |
se_51433378 | stackoverflow | MACHINE_LEARNING | What does model.train() do in PyTorch? | What does model.train() do in PyTorch?
Does it call forward() in nn.Module? I thought when we call the model, forward method is being used.
Why do we need to specify train()? | https://stackoverflow.com/questions/51433378/what-does-model-train-do-in-pytorch | python, machine-learning, deep-learning, pytorch | 1,532,045,400 |
se_79715567 | stackoverflow | MACHINE_LEARNING | `torch.load` is unable to load model weights or variables | `torch.load` is unable to load model weights or variables
I have the model file doclayout_yolo.pt in same folder as code weights-script.py. Also, I installed the required packages via the following commands:
python -m pip install doclayout-yolo
python -m pip install huggingface_hub
Code looks like this:
import tor... | https://stackoverflow.com/questions/79715567/torch-load-is-unable-to-load-model-weights-or-variables | python, pytorch, artificial-intelligence, pickle, yolo | 1,753,522,692 |
se_73207309 | stackoverflow | MACHINE_LEARNING | Converting Torch tensor to bytes and saving as a wav file | Converting Torch tensor to bytes and saving as a wav file
I have an audio file data into torch.tensor format. I want to convert it to bytes, and then need to save the file in ".wav" format. (I don't want to save the file directly from tensor to ".wav")
I use the following approach to convert the tensor into bytes, and... | https://stackoverflow.com/questions/73207309/converting-torch-tensor-to-bytes-and-saving-as-a-wav-file | python-3.x, pytorch, tensor, torch | 1,659,442,191 |
se_79737342 | stackoverflow | MACHINE_LEARNING | What is the relationship between Intel Extension for PyTorch and PyTorch XPU versions? | What is the relationship between Intel Extension for PyTorch and PyTorch XPU versions?
A while ago, I was training a deep learning model on a computer without an NVIDIA GPU but with an Intel GPU. I only used the CPU for training, which was painfully slow. It suddenly occurred to me: can the PyTorch framework leverage ... | https://stackoverflow.com/questions/79737342/what-is-the-relationship-between-intel-extension-for-pytorch-and-pytorch-xpu-ver | python, pytorch, artificial-intelligence, intel, xpu | 1,755,363,228 |
se_79621906 | stackoverflow | MACHINE_LEARNING | Error about attention in the last yolo version | Error about attention in the last yolo version
When I want to use YOLO12 in inference, I get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-65468ee2f515> in <cell line: 0>()
----> 1 ... | https://stackoverflow.com/questions/79621906/error-about-attention-in-the-last-yolo-version | python, deep-learning, pytorch, yolo, ultralytics | 1,747,239,904 |
se_79729734 | stackoverflow | MACHINE_LEARNING | While installing pytorch, got missing file that exists | While installing pytorch, got missing file that exists
I am running Ubuntu 22.04 and I've backed python back to 3.10.12 so I can install audio X. I've never worked much with python.
I ran the command pip install aeiou and, after doing a bunch of things, it gets to torch and says.
... many moving lines omitted ...
... | https://stackoverflow.com/questions/79729734/while-installing-pytorch-got-missing-file-that-exists | python, pip, pytorch | 1,754,654,363 |
se_62423921 | stackoverflow | MACHINE_LEARNING | Unable to get cuda available in Jupyter Notebook or Spyder for PyTorch | Unable to get cuda available in Jupyter Notebook or Spyder for PyTorch
I've installed pytorch cuda with pip and conda
when i run this command in IDLE:
>> import torch
>> torch.cuda.is_available()
I get "True",
but in Spyder or Jupyter Notebook it gives as "False" even after updating the package and conda.
The con... | https://stackoverflow.com/questions/62423921/unable-to-get-cuda-available-in-jupyter-notebook-or-spyder-for-pytorch | python, jupyter-notebook, pytorch | 1,592,379,913 |
se_75976333 | stackoverflow | MACHINE_LEARNING | Neural Net: Loss decreasing, but accuracy stays exactly the same | Neural Net: Loss decreasing, but accuracy stays exactly the same
I am new to PyTorch and just tried to build my first Neural Network on the MNIST dataset. In particular, I wanted to followed this tutorial: https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html
My training code looks like this:
for epoch in... | https://stackoverflow.com/questions/75976333/neural-net-loss-decreasing-but-accuracy-stays-exactly-the-same | python, machine-learning, pytorch | 1,681,122,956 |
se_77997725 | stackoverflow | MACHINE_LEARNING | PyTorch Lightning's ReduceLRonPlateau not working properly | PyTorch Lightning's ReduceLRonPlateau not working properly
I have been trying to write a lightning module using both a warmup and an annealing function ReduceLROnPlateau and something really odd is happening. If the program reduces the learning rate, the learning rate simply pops back up to the base value on the n... | https://stackoverflow.com/questions/77997725/pytorch-lightnings-reducelronplateau-not-working-properly | python, pytorch, pytorch-lightning, learning-rate, warm-up | 1,707,953,110 |
se_79736455 | stackoverflow | MACHINE_LEARNING | Replacing WideResNet50 with EfficientNetV2-M in GLASS defect detection model causes Module layer2 not found in the model | Replacing WideResNet50 with EfficientNetV2-M in GLASS defect detection model causes Module layer2 not found in the model
I’m using the GLASS defect detection model and want to replace its default wideresnet50 backbone with efficientnetv2_m in shell/run-custom.sh.However, when I run
bash run-custom.sh
I get the follow... | https://stackoverflow.com/questions/79736455/replacing-wideresnet50-with-efficientnetv2-m-in-glass-defect-detection-model-cau | machine-learning, deep-learning, pytorch, computer-vision, artificial-intelligence | 1,755,263,394 |
se_63215140 | stackoverflow | MACHINE_LEARNING | PyTorch Linear MNIST model training error | PyTorch Linear MNIST model training error
I am creating a binary classifier based on the MNIST dataset using PyTorch. I want my classifier to classify between only 0s and 1s, however, when I train it, the error doesn't decrease and the loss becomes negative.
Here's the error and loss at the first few iterations:
Tr... | https://stackoverflow.com/questions/63215140/pytorch-linear-mnist-model-training-error | python, machine-learning, pytorch, mnist | 1,596,365,637 |
se_71261347 | stackoverflow | MACHINE_LEARNING | RuntimeError: DataLoader worker exited unexpectedly | RuntimeError: DataLoader worker exited unexpectedly
I am new to PyTorch and Machine Learning so I try to follow the tutorial from here:
https://medium.com/@nutanbhogendrasharma/pytorch-convolutional-neural-network-with-mnist-dataset-4e8a4265e118
By copying the code step by step I got the following error for no reason.... | https://stackoverflow.com/questions/71261347/runtimeerror-dataloader-worker-exited-unexpectedly | python, machine-learning, pytorch | 1,645,766,124 |
se_79635282 | stackoverflow | MACHINE_LEARNING | PyTorch Installation fails on MacBook ARM64 | PyTorch Installation fails on MacBook ARM64
I'm working on a computer vision project, but I'm having trouble installing python packages as my MacBook seems to be confused about its own architecture.
I'm trying to install pytorch using
uv add torch
However, I get the following error:
Resolved 60 packages in 113ms ... | https://stackoverflow.com/questions/79635282/pytorch-installation-fails-on-macbook-arm64 | python, pytorch | 1,747,993,996 |
se_70038557 | stackoverflow | MACHINE_LEARNING | python3 torch waning removal | python3 torch waning removal
I have a python script the uses torch and easyocr.
When I run it I get in the terminal my output but also I see two warnings:
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
[W NNPACK.cpp:79] Could not initialize NNPACK! Reason: Unsupported hardware.
I... | https://stackoverflow.com/questions/70038557/python3-torch-waning-removal | python, pytorch, torch | 1,637,342,240 |
se_66750391 | stackoverflow | MACHINE_LEARNING | RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces) | RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces)
I am using Pytorch. I got this RuntimeError while evaluating a model. Any idea how to solve this? | https://stackoverflow.com/questions/66750391/runtimeerror-view-size-is-not-compatible-with-input-tensors-size-and-stride-a | python, machine-learning, deep-learning, pytorch, computer-vision | 1,616,431,812 |
se_57727372 | stackoverflow | MACHINE_LEARNING | How do I get the value of a tensor in PyTorch? | How do I get the value of a tensor in PyTorch?
Printing a tensor x gives:
>>> x = torch.tensor([3])
>>> print(x)
tensor([3])
Indexing x.data gives:
>>> x.data[0]
tensor(3)
How do I get just a regular non-tensor value 3? | https://stackoverflow.com/questions/57727372/how-do-i-get-the-value-of-a-tensor-in-pytorch | python, pytorch, tensor | 1,567,170,492 |
se_79716269 | stackoverflow | MACHINE_LEARNING | Passing sections of tensor to function (can I avoid looping)? | Passing sections of tensor to function (can I avoid looping)?
If I have this tensor
ks=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
and a function
def myfunc(k:torch.tensor, s:float)->torch.tensor:
# do something
return torch.tensor([2.3, 3.4, 5.1, 2.2])
The return value of myfunc is not a constant of the above... | https://stackoverflow.com/questions/79716269/passing-sections-of-tensor-to-function-can-i-avoid-looping | python, pytorch | 1,753,607,076 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.