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_65072694 | stackoverflow | MACHINE_LEARNING | Make sure BERT model does not load pretrained weights? | Make sure BERT model does not load pretrained weights?
I want to make sure my BertModel does not loads pre-trained weights. I am using auto class (hugging face) which loads model automatically.
My question is how do I load bert model without pretrained weights? | https://stackoverflow.com/questions/65072694/make-sure-bert-model-does-not-load-pretrained-weights | pytorch, bert-language-model, huggingface-transformers | 1,606,735,678 |
se_72429838 | stackoverflow | MACHINE_LEARNING | Difference between sum and mean in .backward() in calculating the loss and backpropagated through the network | Difference between sum and mean in .backward() in calculating the loss and backpropagated through the network
I know we should convert the tensor to scalar before applying backward(), but when to sum and when to mean?
some_loss_function.sum().backward()
-OR-
some_loss_function.mean().backward() | https://stackoverflow.com/questions/72429838/difference-between-sum-and-mean-in-backward-in-calculating-the-loss-and-backp | machine-learning, pytorch | 1,653,891,222 |
se_79536891 | stackoverflow | MACHINE_LEARNING | Using zip() on two nn.ModuleList | Using zip() on two nn.ModuleList
Is using two different nn.ModuleList() zipped lists correct to build the computational graph for training a neural net in PyTorch? nn.ModuleList is a wrapper around Python's list with a registration of a module for training.
I'm building a network which consists of 2x interchanging typ... | https://stackoverflow.com/questions/79536891/using-zip-on-two-nn-modulelist | python, machine-learning, deep-learning, pytorch, computer-vision | 1,743,012,149 |
se_79532719 | stackoverflow | MACHINE_LEARNING | My Google Colab GPU refuses to work. It gets connected and also shows that it's connected, but when I train or run anything, my system RAM gets used | My Google Colab GPU refuses to work. It gets connected and also shows that it's connected, but when I train or run anything, my system RAM gets used
My Google Colab GPU doesn't get used even when I am connected to it. I'm trying to run a PyTorch model on Google Colab using the free GPU, but it seems that my code i... | https://stackoverflow.com/questions/79532719/my-google-colab-gpu-refuses-to-work-it-gets-connected-and-also-shows-that-its | tensorflow, pytorch, gpu, google-colaboratory | 1,742,877,992 |
se_79535147 | stackoverflow | MACHINE_LEARNING | How do I avoid CPU for loops when inputs are a function of previous outputs? | How do I avoid CPU for loops when inputs are a function of previous outputs?
I have a simple reinforcement model in pytorch that makes decisions about where it wants to be and receives its current position (e.g. from a GPS) as an input. For the sake of this example let's just assume it can just move anywhere at any po... | https://stackoverflow.com/questions/79535147/how-do-i-avoid-cpu-for-loops-when-inputs-are-a-function-of-previous-outputs | python, pytorch | 1,742,948,503 |
se_79403409 | stackoverflow | MACHINE_LEARNING | How to prevent certain input from impacting certain output of neural networks in pytorch? | How to prevent certain input from impacting certain output of neural networks in pytorch?
I have an LSTM model that receives 5 inputs to predict 3 outputs:
import torch
import torch.nn as nn
class LstmModel(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(CustomLSTMModel, self).... | https://stackoverflow.com/questions/79403409/how-to-prevent-certain-input-from-impacting-certain-output-of-neural-networks-in | python, deep-learning, pytorch, neural-network, lstm | 1,738,341,577 |
se_73480950 | stackoverflow | MACHINE_LEARNING | ModuleNotFoundError: No module named 'pytorch_grad_cam.metrics' | ModuleNotFoundError: No module named 'pytorch_grad_cam.metrics'
Pytorch Grad-Cam was working well with my resnet18 models till 23rd of Aug 2022. Suddenly from today, 24th Aug I am constantly getting this error
ModuleNotFoundError: No module named 'pytorch_grad_cam.metrics'
when I run the code in both, colab ... | https://stackoverflow.com/questions/73480950/modulenotfounderror-no-module-named-pytorch-grad-cam-metrics | pytorch | 1,661,390,624 |
se_51677788 | stackoverflow | MACHINE_LEARNING | Data Augmentation in PyTorch | Data Augmentation in PyTorch
I am a little bit confused about the data augmentation performed in PyTorch. Now, as far as I know, when we are performing data augmentation, we are KEEPING our original dataset, and then adding other versions of it (Flipping, Cropping...etc). But that doesn't seem like happening in PyTorc... | https://stackoverflow.com/questions/51677788/data-augmentation-in-pytorch | python, machine-learning, pytorch, dataset, data-augmentation | 1,533,318,709 |
se_74621525 | stackoverflow | MACHINE_LEARNING | Temporal Fusion Transformer | Temporal Fusion Transformer
I have 5 months (153 days) daily sales data. I want to forecast future 30 days sales. I used Temporal Fusion Transformer to build time series model.
In this case, if I set max_prediction_length = 7, max_encoder_length = 21 it works. When I increase max_prediction_length to 13, an error repo... | https://stackoverflow.com/questions/74621525/temporal-fusion-transformer | python, pytorch, pytorch-lightning, pytorch-forecasting | 1,669,766,213 |
se_52370008 | stackoverflow | MACHINE_LEARNING | Understanding PyTorch Tensor Shape | Understanding PyTorch Tensor Shape
I have a simple question regarding the shape of tensor we define in PyTorch. Let's say if I say:
input = torch.randn(32, 35)
This will create a matrix with 32 row and 35 columns.
Now when I define:
input2 = torch.randn(1,2,32, 35)
What can I say about the dimension of the new m... | https://stackoverflow.com/questions/52370008/understanding-pytorch-tensor-shape | python, pytorch, tensor | 1,537,194,365 |
se_62525680 | stackoverflow | MACHINE_LEARNING | Save only best weights with huggingface transformers | Save only best weights with huggingface transformers
Currently, I'm building a new transformer-based model with huggingface-transformers, where attention layer is different from the original one. I used run_glue.py to check performance of my model on GLUE benchmark. However, I found that Trainer class of huggingface-t... | https://stackoverflow.com/questions/62525680/save-only-best-weights-with-huggingface-transformers | deep-learning, nlp, pytorch, huggingface-transformers | 1,592,873,636 |
se_79528937 | stackoverflow | MACHINE_LEARNING | Regression fails with poor initial guess | Regression fails with poor initial guess
Consider a regression task where the parameters of the model differ significantly in magnitude, say:
def func(x, p):
p1, p2, p3 = p
return np.sin(p1*x) * np.exp(p2*x) * p3
# True Parameters:
p1, p2, p3 = np.pi/0.01, -1.25, 1.2356 # 314.1592, -1.25, 1.2356
The system ... | https://stackoverflow.com/questions/79528937/regression-fails-with-poor-initial-guess | python, machine-learning, optimization, pytorch, regression | 1,742,732,578 |
se_79519074 | stackoverflow | MACHINE_LEARNING | Do Python version issues with TTA lead to fasttransform vs. fastcore bugs in Python >= 3.10? | Do Python version issues with TTA lead to fasttransform vs. fastcore bugs in Python >= 3.10?
Test Time Augmentation (TTA) in FastAI should be easily applied with learn.tta, yet has led to numerous issues in my Cloud Run deployment. I have a working Cloud Run deployment that does base learner and metalearner scoring... | https://stackoverflow.com/questions/79519074/do-python-version-issues-with-tta-lead-to-fasttransform-vs-fastcore-bugs-in-pyt | python, pytorch, prediction, fast-ai | 1,742,355,716 |
se_71382491 | stackoverflow | MACHINE_LEARNING | PyTorch moving average computation creates inplace operation | PyTorch moving average computation creates inplace operation
I have a loss function that depends on an "exponential moving average" Z. A minimal example (pay special attention to the getUpdatedZ function):
import torch
import torch.nn as nn
class FeedForward(nn.Module):
def __init__(self):
super(FeedForwa... | https://stackoverflow.com/questions/71382491/pytorch-moving-average-computation-creates-inplace-operation | pytorch | 1,646,662,840 |
se_51422776 | stackoverflow | MACHINE_LEARNING | How do i add ctc beam search decoder in crnn model (pytorch) | How do i add ctc beam search decoder in crnn model (pytorch)
I am following the CRNN implementation of https://github.com/meijieru/crnn.pytorch, but seems like it is not using beam search for decoding the words. Can someone tell me how to add beam search decoding in the same model? At the same time in Tensorflow, ther... | https://stackoverflow.com/questions/51422776/how-do-i-add-ctc-beam-search-decoder-in-crnn-model-pytorch | tensorflow, deep-learning, ocr, speech-recognition, pytorch | 1,532,003,469 |
se_65886274 | stackoverflow | MACHINE_LEARNING | TypeError: Cannot interpret 'torch.uint8' as a data type | TypeError: Cannot interpret 'torch.uint8' as a data type
Today I have started to learn Pytorch and I stuck here. The code piece in the comment raises this error:
TypeError: Cannot interpret 'torch.uint8' as a data type
For changing the data type of the tensor I used: quzu_torch = quzu_torch.type(torch.float) B... | https://stackoverflow.com/questions/65886274/typeerror-cannot-interpret-torch-uint8-as-a-data-type | python, pytorch | 1,611,583,402 |
se_45906706 | stackoverflow | MACHINE_LEARNING | Pytorch install with anaconda error | Pytorch install with anaconda error
I get this error:
C:\Users>conda install pytorch torchvision -c soumith
Fetching package metadata .............
PackageNotFoundError: Package missing in current win-64 channels:
- pytorch
I got conda install pytorch torchvision -c soumith from Pytorch official website and I ha... | https://stackoverflow.com/questions/45906706/pytorch-install-with-anaconda-error | anaconda, pytorch | 1,503,848,697 |
se_51234035 | stackoverflow | MACHINE_LEARNING | Neural networks pytorch | Neural networks pytorch
I am implementing my own image classifier network. However I see for each epoch training accuracy is very good but validation accuracy is 0 till 5th epoch. I am using Adam optimizer and have learning rate .001. also resampling the whole data set after each epoch into training n validation set. ... | https://stackoverflow.com/questions/51234035/neural-networks-pytorch | python, machine-learning, conv-neural-network, pytorch | 1,531,067,731 |
se_66836846 | stackoverflow | MACHINE_LEARNING | Fastai predict on collaboative learning model | Fastai predict on collaboative learning model
I have a Fast ai collaborative filtering model. I would like to predict on this model for a new tuple.
I am having trouble with the predict function
From their documentation,
Signature: learn.predict(item, rm_type_tfms=None, with_input=False)
Docstring: Prediction on `item... | https://stackoverflow.com/questions/66836846/fastai-predict-on-collaboative-learning-model | machine-learning, pytorch, fast-ai | 1,616,885,360 |
se_79528211 | stackoverflow | MACHINE_LEARNING | Florence2 Torch JiT Inference | Florence2 Torch JiT Inference
I am using the Florence2 model and trying to speed up inference through torch.jit.trace()
Orig model -
import torch
from transformers import AutoProcessor, AutoModelForCausalLM
from PIL import Image
model = AutoModelForCausalLM.from_pretrained(
"microsoft/Florence-2-large",
torch... | https://stackoverflow.com/questions/79528211/florence2-torch-jit-inference | pytorch, torch, large-language-model, huggingface | 1,742,682,607 |
se_51545026 | stackoverflow | MACHINE_LEARNING | Implementing a custom dataset with PyTorch | Implementing a custom dataset with PyTorch
I'm attempting to modify this feedforward network taken from https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/01-basics/feedforward_neural_network/main.py
to utilize my own dataset.
I define a custom dataset of two 1 dim arrays as input and two scalars the cor... | https://stackoverflow.com/questions/51545026/implementing-a-custom-dataset-with-pytorch | python, machine-learning, neural-network, pytorch | 1,532,628,254 |
se_79513638 | stackoverflow | MACHINE_LEARNING | RuntimeError: Pytorch Optimizer | RuntimeError: Pytorch Optimizer
# create a Pytorch optimizer
optimizer = torch.optim.AdamW(model.parameters(), lr=learning_rate)
for iter in range(max_iters):
if iter % eval_iters == 0:
losses = estimate_loss()
print(f"step: {iter}, loss {losses}")
# sample a batch of data
xb, yb... | https://stackoverflow.com/questions/79513638/runtimeerror-pytorch-optimizer | python, optimization, pytorch, jupyter | 1,742,186,190 |
se_76024738 | stackoverflow | MACHINE_LEARNING | RuntimeError: running_mean should contain 1 elements not 200 | RuntimeError: running_mean should contain 1 elements not 200
I am implementing a conditional gan for image generation with text embedding from scratch and I am getting the above error exactly in the BatchNorm1d layer from the embedding_layers in the generator
generator class :
import torch.nn as nn
class Generator(n... | https://stackoverflow.com/questions/76024738/runtimeerror-running-mean-should-contain-1-elements-not-200 | python, pytorch, generative-adversarial-network | 1,681,592,398 |
se_79525759 | stackoverflow | MACHINE_LEARNING | How to suppress warnings from model.load_state_dict() in PyTorch? | How to suppress warnings from model.load_state_dict() in PyTorch?
I'm loading a model checkpoint using
model.load_state_dict(state_dict, strict=False)
because the model architecture does not fully match the weights. As expected, this results in a warning message like this:
The model and loaded state dict do not match... | https://stackoverflow.com/questions/79525759/how-to-suppress-warnings-from-model-load-state-dict-in-pytorch | machine-learning, deep-learning, pytorch | 1,742,567,636 |
se_79524984 | stackoverflow | MACHINE_LEARNING | Error while installing transformer_engine | Error while installing transformer_engine
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for transformer_engine
Running setup.py clean for transformer_engine
Failed to build transformer_engine
ERROR: Failed to build installable w... | https://stackoverflow.com/questions/79524984/error-while-installing-transformer-engine | python, pytorch, torchvision | 1,742,548,168 |
se_79524622 | stackoverflow | MACHINE_LEARNING | torch upgrade throwing error Weights only load failed | torch upgrade throwing error Weights only load failed
torch version is upgraded from "torch==2.5.1" to "torch==2.6.0", but when tried to run below code we are getting error , can anyone please let me know how to resolve this issue?
yolomodel = torch.hub.load(yolov5path, 'custom', source='local', path = yolomodelpath, ... | https://stackoverflow.com/questions/79524622/torch-upgrade-throwing-error-weights-only-load-failed | pytorch, torch | 1,742,535,739 |
se_78126688 | stackoverflow | MACHINE_LEARNING | how can ı activate mps for yolov8 | how can ı activate mps for yolov8
from ultralytics import YOLO
model = YOLO("yolov8n.yaml") # build a new model from scratch
model = YOLO("yolov8n.pt")
model.to("mps")
results = model.train(data='data/datas.yaml',
conf=0.3,
epochs=3,device=‘mps’)
I am trying to train a model on my Yolov8 model, but even if I try for... | https://stackoverflow.com/questions/78126688/how-can-%c4%b1-activate-mps-for-yolov8 | machine-learning, pytorch, yolov8, metal-performance-shaders, macbookpro | 1,709,890,230 |
se_79523864 | stackoverflow | MACHINE_LEARNING | How to update model weights from a custom arbitrary loss function in Pytorch? | How to update model weights from a custom arbitrary loss function in Pytorch?
Starting with the end in mind:
Is there anyway I can write that arbitrary loss function by calling some pytorch functions, thus preserving the autograd graph?
How can I ensure my loss function is "wired" to autograd?
If that cannot be done ... | https://stackoverflow.com/questions/79523864/how-to-update-model-weights-from-a-custom-arbitrary-loss-function-in-pytorch | machine-learning, deep-learning, pytorch, loss-function | 1,742,496,823 |
se_79494100 | stackoverflow | MACHINE_LEARNING | Why does my Llama 3.1 model act differently between AutoModelForCausalLM and LlamaForCausalLM? | Why does my Llama 3.1 model act differently between AutoModelForCausalLM and LlamaForCausalLM?
I have one set of weights, one tokenizer, the same prompt, and identical generation parameters. Yet somehow, when I load the model using AutoModelForCausalLM, I get one output, and when I construct it manually with LlamaForC... | https://stackoverflow.com/questions/79494100/why-does-my-llama-3-1-model-act-differently-between-automodelforcausallm-and-lla | python, machine-learning, pytorch, huggingface, llama | 1,741,422,252 |
se_76817578 | stackoverflow | MACHINE_LEARNING | feedback loop: Expected a 'cpu' device type for generator but found 'mps' | feedback loop: Expected a 'cpu' device type for generator but found 'mps'
I am trying to finetune a HuggingFace model on MacOS M2. However, the torch operator 'aten::random_' does not exist yet for MPS. Therefore, I ran the program with
PYTORCH_ENABLE_MPS_FALLBACK=1
Then I got the following message "... | https://stackoverflow.com/questions/76817578/feedback-loop-expected-a-cpu-device-type-for-generator-but-found-mps | macos, machine-learning, pytorch, huggingface-transformers, metal-performance-shaders | 1,690,961,671 |
se_76939164 | stackoverflow | MACHINE_LEARNING | Running model prompt on stable diffusion model from hugging face on mps MacOS | Running model prompt on stable diffusion model from hugging face on mps MacOS
import gradio as gr
import torch
import numpy as np
import modin.pandas as pd
from PIL import Image
from diffusers import DiffusionPipeline
import os
os.environ["PYTORCH_MPS_HIGH_WATERMARK_RATIO"] = "0.0"
device = 'cuda' if torch.cuda.is_a... | https://stackoverflow.com/questions/76939164/running-model-prompt-on-stable-diffusion-model-from-hugging-face-on-mps-macos | python, machine-learning, pytorch, huggingface, metal-performance-shaders | 1,692,530,864 |
se_76196734 | stackoverflow | MACHINE_LEARNING | Pytorch MPS: 'mps.scatter_nd' op invalid input tensor shape | Pytorch MPS: 'mps.scatter_nd' op invalid input tensor shape
I have set up my model for hyper parameter tuning using either nevergrad or optuna (both result in the same problem).
The problem:
After the first model has trained (i.e. first parameter search), then when the second is about to begin training, I get ... | https://stackoverflow.com/questions/76196734/pytorch-mps-mps-scatter-nd-op-invalid-input-tensor-shape | python, machine-learning, pytorch, metal, metal-performance-shaders | 1,683,503,093 |
se_76991341 | stackoverflow | MACHINE_LEARNING | DataLoader - pytorch inconsistency between cpu and mps - Apple Silicon | DataLoader - pytorch inconsistency between cpu and mps - Apple Silicon
I got stuck on this inconsistency with DataLoader in Pytorch on Mac Apple Silicone.
If I use cpu y is interpreted correctly. However If I use mps it always returns vector with correct length, however only based on first element y[0].
import torch
f... | https://stackoverflow.com/questions/76991341/dataloader-pytorch-inconsistency-between-cpu-and-mps-apple-silicon | python, machine-learning, pytorch, metal-performance-shaders, apple-m2 | 1,693,212,944 |
se_76954976 | stackoverflow | MACHINE_LEARNING | Torch MPS on Intel Mac: get name of device? | Torch MPS on Intel Mac: get name of device?
In Python, on a machine that has an NVIDIA GPU, one can confirm the mps device name of the GPU using:
torch.cuda.get_device_name()
Per the docs: https://pytorch.org/docs/stable/generated/torch.cuda.get_device_name.html#torch.cuda.get_device_name
How do I confirm the mps devi... | https://stackoverflow.com/questions/76954976/torch-mps-on-intel-mac-get-name-of-device | python, macos, machine-learning, pytorch, metal-performance-shaders | 1,692,719,305 |
se_75173055 | stackoverflow | MACHINE_LEARNING | How to resolve "MPS Framework doesn't support float64" on M1 Mac | How to resolve "MPS Framework doesn't support float64" on M1 Mac
I am trying to train a YOLO model on a custom dataset using YOLOv8 Ultralytics, using M1 MacBook Pro MPS acceleration which is supported by PyTorch but I am getting the following error while executing the train command.
Command:
!yolo task=... | https://stackoverflow.com/questions/75173055/how-to-resolve-mps-framework-doesnt-support-float64-on-m1-mac | python, machine-learning, pytorch, yolo, metal-performance-shaders | 1,674,135,282 |
se_79274150 | stackoverflow | MACHINE_LEARNING | Getting RuntimeError: view size is not compatible with input tensor's size and stride while using mps | Getting RuntimeError: view size is not compatible with input tensor's size and stride while using mps
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
Getting this error only while using mps and ... | https://stackoverflow.com/questions/79274150/getting-runtimeerror-view-size-is-not-compatible-with-input-tensors-size-and-s | python, machine-learning, pytorch, metal-performance-shaders | 1,733,988,047 |
se_78523154 | stackoverflow | MACHINE_LEARNING | MPS device and Pytorch | MPS device and Pytorch
I want to rum mpnn with a lightning trainer on my mac.
These are my trainer settings:
trainer = pl.Trainer(
logger=False,
enable_checkpointing=True, #
enable_progress_bar=True,
accelerator="mps",
devices= 1,
max_epochs=20, # number of epochs to train for
)
I also changed... | https://stackoverflow.com/questions/78523154/mps-device-and-pytorch | machine-learning, pytorch, lightning, metal-performance-shaders | 1,716,467,648 |
se_79520329 | stackoverflow | MACHINE_LEARNING | Use subset of dataset in c++ frontend | Use subset of dataset in c++ frontend
I am using MNIST in the c++ frontend, and I want to use a reduced version of it. However, the c++ frontend does not appear to have torch.utils.data.Subset or RandomizedSubsetSampler to use a subset of the dataset like you would in normal pytorch, is there any other possibility?
I ... | https://stackoverflow.com/questions/79520329/use-subset-of-dataset-in-c-frontend | c++, pytorch, mnist | 1,742,390,463 |
se_79521003 | stackoverflow | MACHINE_LEARNING | How to install CPU only version of pytorch using setuptools backed pyproject.toml | How to install CPU only version of pytorch using setuptools backed pyproject.toml
Consider the following pyproject.toml
[build-system]
requires = ["setuptools>=75", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "test"
version = "0.0.1-dev"
requires-python = ">=3.9"
dependencies = [
"tensorflow... | https://stackoverflow.com/questions/79521003/how-to-install-cpu-only-version-of-pytorch-using-setuptools-backed-pyproject-tom | python, pytorch, setuptools, pyproject.toml | 1,742,406,711 |
se_79519918 | stackoverflow | MACHINE_LEARNING | Can PyTorch `scatter` or `gather` be used to reproduce `torch_geometric` aggregation functions? | Can PyTorch `scatter` or `gather` be used to reproduce `torch_geometric` aggregation functions?
I can't understand if torch.scatter or torch.gather could be used to reduce values of a tensor according to a reduction function over specified indices.
I've frequently used the torch_geometric.nn.aggr` module's functions i... | https://stackoverflow.com/questions/79519918/can-pytorch-scatter-or-gather-be-used-to-reproduce-torch-geometric-aggrega | python, pytorch, tensor, torch, reduction | 1,742,380,397 |
se_79517641 | stackoverflow | MACHINE_LEARNING | Transfer learning insightface on my own dataset | Transfer learning insightface on my own dataset
I'm currently working on transfer learning with InsightFace using the glint360k_cosface_r100_fp16_0.1 model from the ArcFace Torch section. However, I'm facing issues with either overfitting or underfitting on my dataset, and I'm not sure what I'm doing wrong. Here are t... | https://stackoverflow.com/questions/79517641/transfer-learning-insightface-on-my-own-dataset | pytorch, face-recognition, transfer-learning, fine-tuning, insightface | 1,742,305,420 |
se_79518779 | stackoverflow | MACHINE_LEARNING | Output inconsistency when using LLM batch inference compared to single input | Output inconsistency when using LLM batch inference compared to single input
I found single LLM input get different output logits when merging into a batch for inference.
Besides, I need to use inputs_embeds as model input.
My test LLM is "Qwen/Qwen2.5-1.5B-Instruct" and the test code is below.
from transformers impor... | https://stackoverflow.com/questions/79518779/output-inconsistency-when-using-llm-batch-inference-compared-to-single-input | pytorch, huggingface-transformers, large-language-model | 1,742,338,710 |
se_76036161 | stackoverflow | MACHINE_LEARNING | Implementing a learning rate warm up and a learning rate schedule using pytorch | Implementing a learning rate warm up and a learning rate schedule using pytorch
I’m trying to implement both a learning rate warmup and a learning rate schedule within my training loop.
I’m currently using this for learning rate warmup, specifically the LinearWarmup(). So this simply ramps up from 0 to max_lr over a g... | https://stackoverflow.com/questions/76036161/implementing-a-learning-rate-warm-up-and-a-learning-rate-schedule-using-pytorch | python, deep-learning, pytorch | 1,681,741,226 |
se_72923901 | stackoverflow | MACHINE_LEARNING | Implement Physics informed Neural Network using pytorch | Implement Physics informed Neural Network using pytorch
I found a very interesting paper, Physics Informed Deep Learning (Part I): Data-driven Solutions of Nonlinear Partial Differential Equations and want to give it a trial. For this, I create a dummy problem and implement what I understand from the paper.
Problem St... | https://stackoverflow.com/questions/72923901/implement-physics-informed-neural-network-using-pytorch | python, deep-learning, neural-network, pytorch | 1,657,392,895 |
se_66857471 | stackoverflow | MACHINE_LEARNING | CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment | CUDA initialization: CUDA unknown error - this may be due to an incorrectly set up environment
I am trying to install torch with CUDA support.
Here is the result of my collect_env.py script:
PyTorch version: 1.7.1+cu101
Is debug build: False
CUDA used to build PyTorch: 10.1
ROCM used to build PyTorch: N/A
OS: Ubuntu ... | https://stackoverflow.com/questions/66857471/cuda-initialization-cuda-unknown-error-this-may-be-due-to-an-incorrectly-set | python, pytorch | 1,617,033,454 |
se_56399151 | stackoverflow | MACHINE_LEARNING | PyTorch - unable to use batchnorm1d with Linear | PyTorch - unable to use batchnorm1d with Linear
Using PyTorch's BatchNorm1D on a 1-D tensor gives the error:
RuntimeError: running_mean should contain 1 elements not 2304
Any suggestions on what might be wrong?
My Code:
self.net_common = nn.Sequential (
nn.Linear(64*64, 48*48),
nn.BatchNorm1d(48*48),
... | https://stackoverflow.com/questions/56399151/pytorch-unable-to-use-batchnorm1d-with-linear | pytorch, batch-normalization | 1,559,322,332 |
se_79484474 | stackoverflow | MACHINE_LEARNING | custom MobileNetV2 on Once-For-All Network architecture search | custom MobileNetV2 on Once-For-All Network architecture search
my group leader assigns the task to reduce the compute cost of mobileNetV2, initially did kernel-size refactoring. I thought to use OFA to check what are the possible modification that can be done. OFA doesn't come with mbv2 by default.
can we run custom m... | https://stackoverflow.com/questions/79484474/custom-mobilenetv2-on-once-for-all-network-architecture-search | pytorch, automl, mobilenet | 1,741,110,089 |
se_79515545 | stackoverflow | MACHINE_LEARNING | CNN Autoencoder takes a very long time to train | CNN Autoencoder takes a very long time to train
I have been training a CNN Autoencoder on binary images (pixels are either 0 or 1) of size 64x64. The model is shown below:
import torch
import torch.nn as nn
import torch.nn.functional as F
class CNNAutoencoder(nn.Module):
"""
Input shape: (B, 1, 64, 64)
""... | https://stackoverflow.com/questions/79515545/cnn-autoencoder-takes-a-very-long-time-to-train | python, deep-learning, pytorch, conv-neural-network, autoencoder | 1,742,239,137 |
se_79373190 | stackoverflow | MACHINE_LEARNING | How can I import name 'preserve_channel_dim' from 'albucore.utils' in Pycharm? | How can I import name 'preserve_channel_dim' from 'albucore.utils' in Pycharm?
I am trying to run Albumentation but I am getting an error:
cannot import name 'preserve_channel_dim' from 'albucore.utils'
I have already installed Albumentation and Abucore libraries.
import albumentations as A
import ma... | https://stackoverflow.com/questions/79373190/how-can-i-import-name-preserve-channel-dim-from-albucore-utils-in-pycharm | pytorch, albumentations | 1,737,432,997 |
se_79512485 | stackoverflow | MACHINE_LEARNING | Why isn't pip finding torch when installing on mac? | Why isn't pip finding torch when installing on mac?
I've tried to use pip to install pytorch but it's saying it's not found.
Command I used: pip install torch
Context: I'm using MacOS 15.3.2; architecture arm64; python 3.13.2
Output from the command:
ERROR: Could not find a version that satisfies the requirement t... | https://stackoverflow.com/questions/79512485/why-isnt-pip-finding-torch-when-installing-on-mac | python-3.x, macos, pytorch, pip | 1,742,123,944 |
se_78320397 | stackoverflow | MACHINE_LEARNING | RuntimeError: Library cublas64_12.dll is not found or cannot be loaded. While using WhisperX diarization | RuntimeError: Library cublas64_12.dll is not found or cannot be loaded. While using WhisperX diarization
I was trying to use whisperx to do speaker diarization. I did it sucessfully on google colab but I'm encountering this error while tyring to transcribe the audio file.
Traceback (most recent call last): File "D:\Pr... | https://stackoverflow.com/questions/78320397/runtimeerror-library-cublas64-12-dll-is-not-found-or-cannot-be-loaded-while-us | pytorch, openai-whisper, speaker-diarization | 1,713,007,109 |
se_79323285 | stackoverflow | MACHINE_LEARNING | Executorch installation issue | Executorch installation issue
I am trying to set up environmenty like in tutorial: https://pytorch.org/executorch/stable/getting-started-setup
When running ./install_requirements.sh
I get an error:
CMake Error at CMakeLists.txt:45 (project):
Generator
NMake Makefiles
does not support toolset specification, but tool... | https://stackoverflow.com/questions/79323285/executorch-installation-issue | python, pytorch | 1,735,809,755 |
se_74191070 | stackoverflow | MACHINE_LEARNING | Why are there two different flags to disable gradient computation in PyTorch? | Why are there two different flags to disable gradient computation in PyTorch?
I am an intermediate learner in PyTorch and in some recent cases, I have seen people use the torch.inference_mode() instead of the famous torch.no_grad() while validating your trained agent in reinforcement learning (RL) experiments. I check... | https://stackoverflow.com/questions/74191070/why-are-there-two-different-flags-to-disable-gradient-computation-in-pytorch | python, pytorch, gradient, autograd | 1,666,686,113 |
se_79511518 | stackoverflow | MACHINE_LEARNING | model.eval() return a NoneType object when using deepspeed | model.eval() return a NoneType object when using deepspeed
When I want to accelerate the model training by using deepspeed, a problem occured when I want to evaluate the model on validation dataset. Here is the problem code snippet:
def evaluate(self, epoch_num=None, keep_all=True):
print("self.model:", self.m... | https://stackoverflow.com/questions/79511518/model-eval-return-a-nonetype-object-when-using-deepspeed | python, pytorch, transformer-model, deepspeed | 1,742,059,737 |
se_79510910 | stackoverflow | MACHINE_LEARNING | BatchNormalization mismatch between Pytorch and Keras | BatchNormalization mismatch between Pytorch and Keras
I have built a U-Net like architecture called DF-Net for image manipulation localization. I implemented the model in Pytroch but found later the model's saved metadata and so on in Keras format. I loaded all weights from the Keras's model to Pytorch.
The Torch mode... | https://stackoverflow.com/questions/79510910/batchnormalization-mismatch-between-pytorch-and-keras | python, keras, pytorch, batch-normalization | 1,742,032,132 |
se_77762546 | stackoverflow | MACHINE_LEARNING | How to install pytorch=1.0 and why pytorch installing command no longer work | How to install pytorch=1.0 and why pytorch installing command no longer work
In https://pytorch.org/get-started/previous-versions/, the way to install pytorch 1.0 is to run "conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch". It failed because pytorch==1.0.0 can no longer be found. How should I fix th... | https://stackoverflow.com/questions/77762546/how-to-install-pytorch-1-0-and-why-pytorch-installing-command-no-longer-work | installation, pytorch, abi | 1,704,429,443 |
se_79487620 | stackoverflow | MACHINE_LEARNING | How to create PyTorch tensor immediately in shared memory? | How to create PyTorch tensor immediately in shared memory?
I need to create a PyTorch tensor (CPU) and allocate space for it. The tensor is multi-gigabyte and fits in RAM only once.
I need it shared, because it is later utilized by data retrieval workers which are executed in additional spawned processes (DataLoader w... | https://stackoverflow.com/questions/79487620/how-to-create-pytorch-tensor-immediately-in-shared-memory | windows, ubuntu, pytorch | 1,741,206,665 |
se_68518683 | stackoverflow | MACHINE_LEARNING | Python multiprocessing on multiple CPUs, GPUs | Python multiprocessing on multiple CPUs, GPUs
I have 8 GPUs, 64 CPU cores (multiprocessing.cpu_count()=64)
I am trying to get inference of multiple video files using a deep learning model. I want some files to get processed on each of the 8 GPUs. For each GPU, I want a different 6 CPU cores utilized.
Below python file... | https://stackoverflow.com/questions/68518683/python-multiprocessing-on-multiple-cpus-gpus | python, pytorch, python-multiprocessing, multiprocess, cpu-cores | 1,627,217,273 |
se_78346857 | stackoverflow | MACHINE_LEARNING | How to install GLIBCXX_3.4.29 in Miniconda? | How to install GLIBCXX_3.4.29 in Miniconda?
Background: I work on a server where I am not a sudo-er. I work with Miniconda, the portable version of Anaconda and install all my libraries there.
Now, I am working on a project that requires me to install either pyg-lib or torch-sparse. And I did install them using their ... | https://stackoverflow.com/questions/78346857/how-to-install-glibcxx-3-4-29-in-miniconda | pytorch, conda, glibc, pytorch-geometric | 1,713,437,630 |
se_79509349 | stackoverflow | MACHINE_LEARNING | Correctly invoke TorchEval AUC calculation for two tensors | Correctly invoke TorchEval AUC calculation for two tensors
I am new to torcheval and trying to measure the AUC of my binary classifier (doc).
I notice that while classifier accuracy is decent, the AUC metric evaluates to below 0.5, which is incorrect (given that accuracy is better than 50/50 and my classes are balance... | https://stackoverflow.com/questions/79509349/correctly-invoke-torcheval-auc-calculation-for-two-tensors | python, pytorch, auc | 1,741,962,403 |
se_79508526 | stackoverflow | MACHINE_LEARNING | How to specify a nightly Pytorch version in environment.yml | How to specify a nightly Pytorch version in environment.yml
Consider the following environment.yml file:
channels:
- nvidia
- defaults
- conda-forge
dependencies:
- bottleneck>=1.3.6
- catboost>=0.24.4
...
- pip:
- xgboost==2.1.4
...
How do I add the following pip command to the yml file without... | https://stackoverflow.com/questions/79508526/how-to-specify-a-nightly-pytorch-version-in-environment-yml | python, pytorch, pip, conda | 1,741,941,991 |
se_79507748 | stackoverflow | MACHINE_LEARNING | Why does setting requires_grad=True upon tensor creation specifically cause loss of leaf status after transfer to GPU? | Why does setting requires_grad=True upon tensor creation specifically cause loss of leaf status after transfer to GPU?
I have not been able to wrap my head around this, and ChatGPT seems to think this shouldn't be the case. Why does setting requires_grad=True when creating a tensor cause it to lose its leaf status whe... | https://stackoverflow.com/questions/79507748/why-does-setting-requires-grad-true-upon-tensor-creation-specifically-cause-loss | pytorch | 1,741,903,820 |
se_79502682 | stackoverflow | MACHINE_LEARNING | torch cannot load a pth file containing plotly figures | torch cannot load a pth file containing plotly figures
I am running a bunch of DNN experiments using pytorch, and saving an instance of my ExperimentClass as a .pth file. The ExperimentClass has instance variables including a torch model, a dictionary of multiple plotly figure objects, dataframes, and other metadata r... | https://stackoverflow.com/questions/79502682/torch-cannot-load-a-pth-file-containing-plotly-figures | deep-learning, pytorch, plotly, pth | 1,741,756,093 |
se_77811886 | stackoverflow | MACHINE_LEARNING | How to decide the 'input_size' parameter of torchsummary.summary(model=model.policy, input_size=(int, int, int))? | How to decide the 'input_size' parameter of torchsummary.summary(model=model.policy, input_size=(int, int, int))?
This is my CNN network printed by 'print(model.policy)':
CnnPolicy(
(actor): Actor(
(features_extractor): CustomCNN(
(cnn): Sequential(
(0): Conv2d(1, 32, kernel_size=(3, 3), st... | https://stackoverflow.com/questions/77811886/how-to-decide-the-input-size-parameter-of-torchsummary-summarymodel-model-pol | python, network-programming, pytorch, conv-neural-network | 1,705,158,025 |
se_74864306 | stackoverflow | MACHINE_LEARNING | Not able to import pipelines from tensorflow | Not able to import pipelines from tensorflow
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
No module named 'torch.distributed'
This is the error while im trying to import pipeline from transformer.
My tensorflow is upraded to latesr version 2.11.0 ... | https://stackoverflow.com/questions/74864306/not-able-to-import-pipelines-from-tensorflow | python, python-3.x, tensorflow, pytorch, huggingface-transformers | 1,671,545,218 |
se_79477154 | stackoverflow | MACHINE_LEARNING | RuntimeError: Trying to backward through the graph a second time – How to resolve without using retain_graph=True? | RuntimeError: Trying to backward through the graph a second time – How to resolve without using retain_graph=True?
I’m working on a neural Turing Machine (NTM) model in PyTorch that uses a controller with 2D attention fusion. During training, I encounter the following error when calling .backward() on my loss:
Runtime... | https://stackoverflow.com/questions/79477154/runtimeerror-trying-to-backward-through-the-graph-a-second-time-how-to-resolv | pytorch, neural-network, runtime-error, backpropagation, autograd | 1,740,807,911 |
se_79492085 | stackoverflow | MACHINE_LEARNING | Is there an API to tell whether a quantized PyTorch operator is supported by ONNX export? | Is there an API to tell whether a quantized PyTorch operator is supported by ONNX export?
On this PyTorch webpage, it has a list of torchscript operators that are supported/unsupported by ONNX export. What I want to know is, is there a PyTorch/ONNX API-based method to look-up/tell if a particular PyTorch module, in my... | https://stackoverflow.com/questions/79492085/is-there-an-api-to-tell-whether-a-quantized-pytorch-operator-is-supported-by-onn | pytorch, onnx | 1,741,345,669 |
se_79504403 | stackoverflow | MACHINE_LEARNING | pytorch code messes up my RAM when using torch.zeros() | pytorch code messes up my RAM when using torch.zeros()
I have a function to measure the allocated ram by python in megabytes:
def getram(): print(psutil.Process(os.getpid()).memory_info().rss / 1024**2)
And also I have:
device = "cuda"
My problem is that the following code allocates RAM and I'm going crazy because of ... | https://stackoverflow.com/questions/79504403/pytorch-code-messes-up-my-ram-when-using-torch-zeros | python, pytorch, dataset, ram | 1,741,800,093 |
se_79502752 | stackoverflow | MACHINE_LEARNING | Getting Cuda out of memory when importing microsoft/Orca-2-13b from hugging faces | Getting Cuda out of memory when importing microsoft/Orca-2-13b from hugging faces
I am using Ubuntu 24.04.1 on an AWS EC2 instance g5.8xlarge.
I am receiving the following error message:
OutOfMemoryError: Allocation on device
Code:
import os
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "backend:cudaMallocAsync"
import to... | https://stackoverflow.com/questions/79502752/getting-cuda-out-of-memory-when-importing-microsoft-orca-2-13b-from-hugging-face | machine-learning, pytorch, huggingface-transformers, huggingface | 1,741,759,557 |
se_79501962 | stackoverflow | MACHINE_LEARNING | Pytorch Lightning logs separately for train, validation and test datasets | Pytorch Lightning logs separately for train, validation and test datasets
I am trying to log the loss and auc for all 3 of my datasets - train, validation and test.
The datamodule defines the 3 loaders and I finally invoke the model as:
trainer.fit(model,datamodule)
trainer.test(model,datamodule)
This ends up creatin... | https://stackoverflow.com/questions/79501962/pytorch-lightning-logs-separately-for-train-validation-and-test-datasets | pytorch, pytorch-lightning | 1,741,722,866 |
se_79501263 | stackoverflow | MACHINE_LEARNING | Calculate the gradient with respect to attention but also the FFN layers for a pre-trained LLMs | Calculate the gradient with respect to attention but also the FFN layers for a pre-trained LLMs
I would like to return the gradient with respect to specific layers and the FFN layer in the Transformer architecture of pre-trained LLMs from the hugging-face model. Is that even possible?
I am working with the code of thi... | https://stackoverflow.com/questions/79501263/calculate-the-gradient-with-respect-to-attention-but-also-the-ffn-layers-for-a-p | python, pytorch, nlp, large-language-model | 1,741,706,517 |
se_66258464 | stackoverflow | MACHINE_LEARNING | How can I limit the range of parameters in pytorch? | How can I limit the range of parameters in pytorch?
So normally in pytorch, there is no strict limit to the parameters in models, but what if I wanted them to stay in the range [0,1]? Is there a way to block the update of parameters to outside that range? | https://stackoverflow.com/questions/66258464/how-can-i-limit-the-range-of-parameters-in-pytorch | pytorch | 1,613,645,470 |
se_74917772 | stackoverflow | MACHINE_LEARNING | How to make an empty tensor in Pytorch? | How to make an empty tensor in Pytorch?
In python, we can make an empty list easily by doing a = []. I want to do a similar thing but with Pytorch tensors.
If you want to know why I need that, I want to get all of the data inside a given dataloader (to create another customer dataloader). Having an empty tensor can he... | https://stackoverflow.com/questions/74917772/how-to-make-an-empty-tensor-in-pytorch | python, pytorch, tensor | 1,672,036,247 |
se_79501647 | stackoverflow | MACHINE_LEARNING | How to produce tensor of first occurrencies of another tensor using PyTorch | How to produce tensor of first occurrencies of another tensor using PyTorch
Let's say we have an ordered 1D tensor of ints/longs t.
I want to produce a new tensor a with size max(t) where each term a[i] contains the first occurrence of the value i in the tensor t.
We could easily compute the tensor a using standard Py... | https://stackoverflow.com/questions/79501647/how-to-produce-tensor-of-first-occurrencies-of-another-tensor-using-pytorch | python, python-3.x, pytorch, sparse-matrix, tensor | 1,741,714,636 |
se_79501609 | stackoverflow | MACHINE_LEARNING | How to extract a pytorch network container class name | How to extract a pytorch network container class name
Assume I have a network created as follows:
p = torch.nn.Sequential(torch.nn.Linear(self.inputSize, self.outputSize))
I know that I can print the network with:
print(p)
and get:
Sequential(
(0): Linear(in_features=22, out_features=3, bias=True)
)
I want to prett... | https://stackoverflow.com/questions/79501609/how-to-extract-a-pytorch-network-container-class-name | python, pytorch | 1,741,713,739 |
se_79499231 | stackoverflow | MACHINE_LEARNING | Why is Pytorch Cuda not detecting my GPU? | Why is Pytorch Cuda not detecting my GPU?
Here's a slice of my code:
import torch
print(torch.cuda.is_available())
print("CUDA Version:", torch.version.cuda)
Here's the output:
False
CUDA Version: 12.6
I looked at task manager, and it says I have a GPU. I tried installing Pytorch with GPU support using this Powershe... | https://stackoverflow.com/questions/79499231/why-is-pytorch-cuda-not-detecting-my-gpu | pytorch | 1,741,643,209 |
se_79498420 | stackoverflow | MACHINE_LEARNING | Computing Gradient of Loss w.r.t Learning Rate PyTorch | Computing Gradient of Loss w.r.t Learning Rate PyTorch
I am building a custom optimizer that samples learning rates from a Dirichlet distribution, whose parameters (alpha) need to be updated in each backpropagation. I've already figured out how to get the loss w.r.t. to these alpha parameters, effectively this would b... | https://stackoverflow.com/questions/79498420/computing-gradient-of-loss-w-r-t-learning-rate-pytorch | machine-learning, optimization, deep-learning, pytorch, backpropagation | 1,741,619,462 |
se_79447060 | stackoverflow | MACHINE_LEARNING | Running Stable Diffusion locally | Running Stable Diffusion locally
I've been trying to follow the instructions here to run StableDiffusion locally, but the code appears to just hang.
I've cloned the repo, and installed dependencies:
$ git show --stat
commit cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf (HEAD -> main, origin/main, origin/HEAD)
Author: ha... | https://stackoverflow.com/questions/79447060/running-stable-diffusion-locally | pytorch, torch, stable-diffusion | 1,739,849,548 |
se_69958526 | stackoverflow | MACHINE_LEARNING | OSError: [WinError 127] The specified procedure could not be found | OSError: [WinError 127] The specified procedure could not be found
While importing torch (import torch) I'm facing the following error message:
OSError: [WinError 127] The specified procedure could not be found. Error loading "C:\Users\myUserName\anaconda3\lib\site-packages\torch\lib\jitbackend_test.dll" or one of its... | https://stackoverflow.com/questions/69958526/oserror-winerror-127-the-specified-procedure-could-not-be-found | python, pytorch, conda, windows-11 | 1,636,840,037 |
se_78579409 | stackoverflow | MACHINE_LEARNING | How I can load model and inference using Libtorch (C++)? | How I can load model and inference using Libtorch (C++)?
I trained simple model for MNIST using it https://github.com/pytorch/examples/blob/main/cpp/mnist/mnist.cpp
I added code for saving model like below
string model_path = "model.pt";
torch::serialize::OutputArchive output_archive;
model.save(output_archive);
outpu... | https://stackoverflow.com/questions/78579409/how-i-can-load-model-and-inference-using-libtorch-c | c++, pytorch, torch, libtorch | 1,717,572,939 |
se_79493986 | stackoverflow | MACHINE_LEARNING | Error during SFT training of Qwen2.5-Coder-1.5B: "element 0 of tensors does not require grad and does not have a grad_fn"have a grad_fn` | Error during SFT training of Qwen2.5-Coder-1.5B: "element 0 of tensors does not require grad and does not have a grad_fn"have a grad_fn`
I'm encountering an error during the supervised fine-tuning (SFT) of Qwen2.5-Coder-1.5B. The error, shown in the log below, seems to indicate that something is interrupting... | https://stackoverflow.com/questions/79493986/error-during-sft-training-of-qwen2-5-coder-1-5b-element-0-of-tensors-does-not | python, pytorch, large-language-model | 1,741,415,315 |
se_65376556 | stackoverflow | MACHINE_LEARNING | How to set hydra's parameter HYDRA_FULL_ERROR? | How to set hydra's parameter HYDRA_FULL_ERROR?
When I use hydra in a python pytorch project, the operation result prompt “Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.”
But i don't konw how to set it. | https://stackoverflow.com/questions/65376556/how-to-set-hydras-parameter-hydra-full-error | python, pytorch, fb-hydra | 1,608,433,085 |
se_57814535 | stackoverflow | MACHINE_LEARNING | "AssertionError: Torch not compiled with CUDA enabled" in spite upgrading to CUDA version | "AssertionError: Torch not compiled with CUDA enabled" in spite upgrading to CUDA version
I figured out this is a popular question, but still I couldn't find a solution for that.
I'm trying to run a simple repository here which uses PyTorch. Although I just upgraded my PyTorch to the latest CUDA version from... | https://stackoverflow.com/questions/57814535/assertionerror-torch-not-compiled-with-cuda-enabled-in-spite-upgrading-to-cud | python, pytorch, conda | 1,567,731,811 |
se_76141647 | stackoverflow | MACHINE_LEARNING | Attempting to install Syft results in AttributeError: module 'syft' has no attribute 'TorchHook' | Attempting to install Syft results in AttributeError: module 'syft' has no attribute 'TorchHook'
I am using Google Colb to execute the program. My Python version is 3.10.11.
!pip install syft==0.8.0.post2 hook = sy.TorchHook(torch)
results in
AttributeError: module 'syft' has no attribute 'TorchHook'
... | https://stackoverflow.com/questions/76141647/attempting-to-install-syft-results-in-attributeerror-module-syft-has-no-attri | python, pytorch, pysyft | 1,682,863,252 |
se_79291415 | stackoverflow | MACHINE_LEARNING | Convert pythorch pth model to onnx with fixed width and variable height | Convert pythorch pth model to onnx with fixed width and variable height
My code uses PyTorch to perform segmentation annotations on PNG images. The input images have a width of 512 pixels or a multiple of this, but the height can range from 400 to 900 pixels. The code, along with the PyTorch model (*.pth file), works ... | https://stackoverflow.com/questions/79291415/convert-pythorch-pth-model-to-onnx-with-fixed-width-and-variable-height | python, pytorch, onnx, onnxruntime | 1,734,531,751 |
se_66811113 | stackoverflow | MACHINE_LEARNING | Why do we need to pass the gradient parameter to the backward function in PyTorch? | Why do we need to pass the gradient parameter to the backward function in PyTorch?
According to the docs, when we call the backward function to the tensor if the tensor is non-scalar (i.e. its data has more than one element) and requires gradient, the function additionally requires specifying gradient.
import torch
a ... | https://stackoverflow.com/questions/66811113/why-do-we-need-to-pass-the-gradient-parameter-to-the-backward-function-in-pytorc | pytorch | 1,616,733,481 |
se_79486105 | stackoverflow | MACHINE_LEARNING | Inconsistent results when training models using different GPUs | Inconsistent results when training models using different GPUs
I've been trying to train a language model (text classification), our lab has two GPUs, a 4090 and a 3090. However, I encountered a perplexing phenomenon during training: the model's performance varies slightly when using different GPUs (or different GPU c... | https://stackoverflow.com/questions/79486105/inconsistent-results-when-training-models-using-different-gpus | machine-learning, pytorch, nvidia, text-classification | 1,741,169,404 |
se_79484953 | stackoverflow | MACHINE_LEARNING | Identifying and removing duplicate columns/rows in sparse binary matrix in PyTorch | Identifying and removing duplicate columns/rows in sparse binary matrix in PyTorch
Let's suppose we have a binary matrix A with shape n x m,
I want to identify rows that have duplicates in the matrix, i.e. there is another index on the same dimension with the same elements in the same positions.
It's very important no... | https://stackoverflow.com/questions/79484953/identifying-and-removing-duplicate-columns-rows-in-sparse-binary-matrix-in-pytor | python, pytorch, duplicates, sparse-matrix, tensor | 1,741,124,922 |
se_44328530 | stackoverflow | MACHINE_LEARNING | How to get a uniform distribution in a range [r1,r2] in PyTorch? | How to get a uniform distribution in a range [r1,r2] in PyTorch?
I want to get a 2-D torch.Tensor with size [a,b] filled with values from a uniform distribution (in range [r1,r2]) in PyTorch. | https://stackoverflow.com/questions/44328530/how-to-get-a-uniform-distribution-in-a-range-r1-r2-in-pytorch | python, pytorch, uniform-distribution | 1,496,405,132 |
se_79482885 | stackoverflow | MACHINE_LEARNING | Separable convolutions in PyTorch (i.e. 2 1D-vector-tensor "traditional" convolutions) | Separable convolutions in PyTorch (i.e. 2 1D-vector-tensor "traditional" convolutions)
I'm trying to implement an image filter in PyTorch that takes in two filters of shapes (1,3), (3,1) that build up a filter of (3,3). An example application of this is the Sobel filter or Gaussian blurring
I have a NumPy im... | https://stackoverflow.com/questions/79482885/separable-convolutions-in-pytorch-i-e-2-1d-vector-tensor-traditional-convolu | python, pytorch, convolution, imagefilter | 1,741,072,073 |
se_73256206 | stackoverflow | MACHINE_LEARNING | How to pad the left side of a list of tensors in pytorch to the size of the largest list? | How to pad the left side of a list of tensors in pytorch to the size of the largest list?
In pytorch, if you have a list of tensors, you can pad the right side using torch.nn.utils.rnn.pad_sequence
import torch
'for the collate function, pad the sequences'
f = [
[0,1],
[0, 3, 4],
[4, 3, 2, 4, 3]
]
torch.... | https://stackoverflow.com/questions/73256206/how-to-pad-the-left-side-of-a-list-of-tensors-in-pytorch-to-the-size-of-the-larg | pytorch | 1,659,743,243 |
se_79453817 | stackoverflow | MACHINE_LEARNING | ONNX export stops without error and no onnx file is generated | ONNX export stops without error and no onnx file is generated
I'm trying to export my PyTorch model to ONNX format while ensuring that the batch size remains dynamic. the result always is Segmentation fault (core dumped) Here’s the code I’m using:
import torch # Import PyTorch library
# Create a dummy input tensor o... | https://stackoverflow.com/questions/79453817/onnx-export-stops-without-error-and-no-onnx-file-is-generated | python, deep-learning, deployment, pytorch, onnx | 1,740,040,705 |
se_72898992 | stackoverflow | MACHINE_LEARNING | CrossEntropyLoss for multi-label time series | CrossEntropyLoss for multi-label time series
I'm confused on how to apply cross entropy loss for my time series model where the output is in the shape of [batch_size, classes, time_steps] and target of shape [batch_size, time_steps, classes]. I'm trying to made the model determine the confidence of the 16 classes at e... | https://stackoverflow.com/questions/72898992/crossentropyloss-for-multi-label-time-series | pytorch, loss-function, loss, temporal | 1,657,201,629 |
se_79483120 | stackoverflow | MACHINE_LEARNING | RuntimeError: Given groups=1, weight of size [64, 3, 3, 7, 7], expected input[1, 8, 3, 112, 112] to have 3 channels, but got 8 channels instead | RuntimeError: Given groups=1, weight of size [64, 3, 3, 7, 7], expected input[1, 8, 3, 112, 112] to have 3 channels, but got 8 channels instead
import os
import shutil
import random
import torch
import torchvision.transforms as transforms
import cv2
import numpy as np
from torch.utils.data import Dataset, DataLoader
i... | https://stackoverflow.com/questions/79483120/runtimeerror-given-groups-1-weight-of-size-64-3-3-7-7-expected-input1 | python, pytorch, conv-neural-network, lstm, pytorch-dataloader | 1,741,078,308 |
se_71770920 | stackoverflow | MACHINE_LEARNING | Network stops learning once batchsize is set to > 1 | Network stops learning once batchsize is set to > 1
I started switching from Keras to Pytorch and played around with some simple feedforward network today. It is supposed to learn the squaring operation, i.e. f(x) = x^2. However, my network only learns reasonably if I set the batchsize to 1. Any other batchsize yie... | https://stackoverflow.com/questions/71770920/network-stops-learning-once-batchsize-is-set-to-1 | python, pytorch, batchsize | 1,649,264,710 |
se_79474519 | stackoverflow | MACHINE_LEARNING | Runtime Error while trying to train RTDetrV2 with Transformer | Runtime Error while trying to train RTDetrV2 with Transformer
I am trying to train RTDetrV2 for detection on water meter digit. I use an ipynb file form here https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-rt-detr-on-custom-dataset-with-transformers.ipynb#scrollTo=a7kZr8OtGkIO.... | https://stackoverflow.com/questions/79474519/runtime-error-while-trying-to-train-rtdetrv2-with-transformer | python, machine-learning, pytorch, huggingface-transformers, roboflow | 1,740,717,329 |
se_78164797 | stackoverflow | MACHINE_LEARNING | Could not find a version that satisfies the requirement llama-index-finetuning-cross-encoders | Could not find a version that satisfies the requirement llama-index-finetuning-cross-encoders
I'm trying to run this Llama Index How to Finetune a cross-encoder using LLamaIndex.
But I cannot install llama-index-finetuning-cross-encoders package.
I tried this code
%pip install llama-index-finetuning-cross-encoders
Bu... | https://stackoverflow.com/questions/78164797/could-not-find-a-version-that-satisfies-the-requirement-llama-index-finetuning-c | pytorch, large-language-model, llama-index, fine-tuning | 1,710,479,549 |
se_74183185 | stackoverflow | MACHINE_LEARNING | Removing padding from tensor | Removing padding from tensor
I have a tensor like:
tensor([[ 9, -1, -1],
[ 7, -1, -1],
[ 6, 4, -1]])
What is the most efficient way to remove the padding and get something like:
[[9], [7], [ 6, 4]])
Thanks in advance for any help you can provide. | https://stackoverflow.com/questions/74183185/removing-padding-from-tensor | pytorch | 1,666,623,947 |
se_79475046 | stackoverflow | MACHINE_LEARNING | PyTorch gradient of loss (that depends on gradient of network) with respect to parameters | PyTorch gradient of loss (that depends on gradient of network) with respect to parameters
I'm trying to compute the gradient of my loss function with respect to my model parameters in PyTorch.
That is, let u(x; θ) be the model, where x is the input (in R^n) and θ are the model parameters. I'm trying to compute du/dθ.
... | https://stackoverflow.com/questions/79475046/pytorch-gradient-of-loss-that-depends-on-gradient-of-network-with-respect-to-p | pytorch | 1,740,734,827 |
se_79478715 | stackoverflow | MACHINE_LEARNING | pytorch after load model state_dict training loss keep increasing | pytorch after load model state_dict training loss keep increasing
Im training a model and in the first training, no matter how many epochs (10,20,30…) i trained the model, everything looks great! the acc was increasing and the loss was decreasing as well. but when i load the saving model and retrain this model, the lo... | https://stackoverflow.com/questions/79478715/pytorch-after-load-model-state-dict-training-loss-keep-increasing | python, pytorch, lstm, embedding, state-dict | 1,740,898,334 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.