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_79725054
stackoverflow
MACHINE_LEARNING
RuntimeError in torch.cat during VACE-Wan2.1 inference: mask and video tensor shape mismatch
RuntimeError in torch.cat during VACE-Wan2.1 inference: mask and video tensor shape mismatch I'm using the Wan2.1-VACE video generation model, and during inference I encountered a RuntimeError related to mismatched tensor shapes in a torch.cat operation inside the vace_latent() function. From the debug output: src_vid...
https://stackoverflow.com/questions/79725054/runtimeerror-in-torch-cat-during-vace-wan2-1-inference-mask-and-video-tensor-sh
python, machine-learning, deep-learning, pytorch, computer-vision
1,754,318,209
se_79727929
stackoverflow
MACHINE_LEARNING
How to compare the numerical precision of two different tensors
How to compare the numerical precision of two different tensors I'm trying to compare the output of two tensors with different numerical precisions: one in float64 (fp64) and the other in float32 (fp32). Both tensors are computed from the same inputs and represent the same operation or result, just at different precis...
https://stackoverflow.com/questions/79727929/how-to-compare-the-numerical-precision-of-two-different-tensors
python, pytorch, precision, numeric
1,754,520,498
se_79705928
stackoverflow
MACHINE_LEARNING
Using DataLoader for efficient model prediction
Using DataLoader for efficient model prediction I'm trying to understand the role/utility of batch_size in torch beyond model training. I already have a trained model, where the batch_size was optimized as a hyperparameter. I want to use the model to make predictions in new data. I'm following the same format of the i...
https://stackoverflow.com/questions/79705928/using-dataloader-for-efficient-model-prediction
python, pytorch, pytorch-dataloader
1,752,829,153
se_79665616
stackoverflow
MACHINE_LEARNING
CUDA error: no kernel image is available for execution on the device
CUDA error: no kernel image is available for execution on the device Im using the latest LibTorch with CUDA 12.6 installed on Windows 10 Libtorch is showing CUDA is available, however, I get this error when I try to use device = torch::Device(torch::kCUDA, 0); network.to(device) Am I missing some installation? Is...
https://stackoverflow.com/questions/79665616/cuda-error-no-kernel-image-is-available-for-execution-on-the-device
pytorch, cuda, libtorch
1,749,881,182
se_79727368
stackoverflow
MACHINE_LEARNING
Why does my flwr federated learning setup freeze at round 1 while on deployment engine?
Why does my flwr federated learning setup freeze at round 1 while on deployment engine? I'm new to the federated learning systems and I'm trying to train a model using 2 supernodes (clients). I managed to start the superlink (server) succesfully and successfully connect the nodes to the server and when I run the proje...
https://stackoverflow.com/questions/79727368/why-does-my-flwr-federated-learning-setup-freeze-at-round-1-while-on-deployment
python, pytorch, artificial-intelligence, flower, federated-learning
1,754,487,635
se_78725972
stackoverflow
MACHINE_LEARNING
What parameter do I need to change for it to match requirements?
What parameter do I need to change for it to match requirements? I am trying to train a model based on a modified MNIST dataset so it classifies random images with label 10. I am constantly getting a TypeError. transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,)) ]...
https://stackoverflow.com/questions/78725972/what-parameter-do-i-need-to-change-for-it-to-match-requirements
machine-learning, pytorch, mnist, pytorch-dataloader
1,720,532,622
se_79724468
stackoverflow
MACHINE_LEARNING
Pytorch compute graph don't release as expected
Pytorch compute graph don't release as expected import torch def analyze_your_actual_code(): """分析你的实际代码""" a = torch.randn(4, requires_grad=True) print(f"a: {a}") print(f"a.grad: {a.grad}") loss = a.sum() loss.backward() print(f" a.grad: {a.grad}") loss.backward() ...
https://stackoverflow.com/questions/79724468/pytorch-compute-graph-dont-release-as-expected
python, pytorch, gradient
1,754,280,230
se_79721249
stackoverflow
MACHINE_LEARNING
Learnable parameter only updating non-zero values and identically during training
Learnable parameter only updating non-zero values and identically during training I have the following code in Python3.11 using PyTorch: arr = np.array([[0, 0, 0], [0, -1, 0], [0, 1, 0]]) arr_tensor = torch.tensor(arr, dtype=torch.float32, device=device).unsqueeze(0).repeat(5, 1, 1, 1,...
https://stackoverflow.com/questions/79721249/learnable-parameter-only-updating-non-zero-values-and-identically-during-trainin
python, pytorch, tensor
1,753,962,830
se_79559122
stackoverflow
MACHINE_LEARNING
OSError: Qwen/Qwen2.5-VL-7B-Instruct does not appear to have files named model-00002-of-00005.safetensors despite having the file locally
OSError: Qwen/Qwen2.5-VL-7B-Instruct does not appear to have files named model-00002-of-00005.safetensors despite having the file locally I'm trying to use the Qwen2.5-VL-7B model for my project, and I've downloaded a local file named model-00002-of-00005.safetensors. However, when I run my code, I encounter the follo...
https://stackoverflow.com/questions/79559122/oserror-qwen-qwen2-5-vl-7b-instruct-does-not-appear-to-have-files-named-model-0
python, deep-learning, pytorch, fine-tuning, oserror
1,744,003,354
se_79316602
stackoverflow
MACHINE_LEARNING
error mat1 and mat2 shapes cannot be multiplied (4x256 and 768x1280) while fine tuning stable video diffusion
error mat1 and mat2 shapes cannot be multiplied (4x256 and 768x1280) while fine tuning stable video diffusion I want to fine tune a stable diffusion model with my dataset. Getting error on line output = lora_unet model used: stable-video-diffusion-img2vid-xt-1-1 Tried some code fixes given by chatgpt but no use. This...
https://stackoverflow.com/questions/79316602/error-mat1-and-mat2-shapes-cannot-be-multiplied-4x256-and-768x1280-while-fine
pytorch, artificial-intelligence, stable-diffusion
1,735,521,266
se_79709893
stackoverflow
MACHINE_LEARNING
DQN fails to learn good policy for Atari Pong
DQN fails to learn good policy for Atari Pong I'm trying to implement the findings from this DeepMind DQN paper (2015) from scratch in PyTorch using the Atari Pong environment. I've tested my Deep Q-Network on a simple test environment, where episodes last only 5 time steps and the maximum achievable reward is 4.1. My...
https://stackoverflow.com/questions/79709893/dqn-fails-to-learn-good-policy-for-atari-pong
python, deep-learning, pytorch, reinforcement-learning
1,753,159,942
se_78152635
stackoverflow
MACHINE_LEARNING
How to activate the adaptive solver in torchdiffeq?
How to activate the adaptive solver in torchdiffeq? In the documentation of the well-known library torchdiffeq, the author have made an user guide with how to use the adaptive solver. However, when doing the instruction (even with using "options"), the step size in my experiment does not change during the time. I wond...
https://stackoverflow.com/questions/78152635/how-to-activate-the-adaptive-solver-in-torchdiffeq
pytorch, open-source, differential-equations
1,710,322,556
se_79704439
stackoverflow
MACHINE_LEARNING
How to solve InvalidArchiveError while installing pytorch with Anaconda?
How to solve InvalidArchiveError while installing pytorch with Anaconda? I have installed the latest Anaconda and updated everything. When I try to install BERTopic or PyTorch itself, I am getting this error: InvalidArchiveError("Error with archive C:\Users\myuser\AppData\Local\anaconda3\pkgs\pytorch-2.6.0-cpu_mkl_py...
https://stackoverflow.com/questions/79704439/how-to-solve-invalidarchiveerror-while-installing-pytorch-with-anaconda
python, pytorch, anaconda, bert-language-model
1,752,737,574
se_69968477
stackoverflow
MACHINE_LEARNING
RuntimeError: CUDA error: no kernel image is available for execution on the device after model.cuda()
RuntimeError: CUDA error: no kernel image is available for execution on the device after model.cuda() I am working on this model: class Model(torch.nn.Module): def __init__(self, sizes, config): super(Model, self).__init__() self.lstm = [] for i in range(len(sizes) - 2): self.l...
https://stackoverflow.com/questions/69968477/runtimeerror-cuda-error-no-kernel-image-is-available-for-execution-on-the-devi
python, pytorch
1,636,938,127
se_79709724
stackoverflow
MACHINE_LEARNING
RuntimeError: CUDA error: named symbol not found when using TorchAoConfig with Qwen2.5-VL-7B-Instruct model
RuntimeError: CUDA error: named symbol not found when using TorchAoConfig with Qwen2.5-VL-7B-Instruct model I'm trying to load the Qwen2.5-VL-7B-Instruct model from hugging face with 4-bit weight-only quantization using TorchAoConfig (similar to how its mentioned in the documentation here), but I'm getting a runtime e...
https://stackoverflow.com/questions/79709724/runtimeerror-cuda-error-named-symbol-not-found-when-using-torchaoconfig-with-q
python, pytorch, huggingface-transformers, huggingface, quantization
1,753,141,279
se_78806145
stackoverflow
MACHINE_LEARNING
Is there a way to generate the computation graph of a PyTorch model from just a forward pass?
Is there a way to generate the computation graph of a PyTorch model from just a forward pass? Imagine a network like this: import torch import torch.nn as nn class CoolCNN(nn.Module): def __init__(self): super(CoolCNN, self).__init__() self.initial_conv = nn.Conv2d(in_channels=3, out_channels=16, ...
https://stackoverflow.com/questions/78806145/is-there-a-way-to-generate-the-computation-graph-of-a-pytorch-model-from-just-a
python, graph, pytorch
1,722,242,716
se_79713748
stackoverflow
MACHINE_LEARNING
Move elements up in a one dimensional torch tensor
Move elements up in a one dimensional torch tensor If I have a torch tensor of the form: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] .roll simply moves the elements down [6.0, 1.0, 2.0, 3.0, 4.0, 5.0] I want it to roll the other way resulting in [2.0, 3.0, 4.0, 5.0, 6.0, 1.0] (in fact, the last element will be zero'd in this p...
https://stackoverflow.com/questions/79713748/move-elements-up-in-a-one-dimensional-torch-tensor
python, pytorch
1,753,377,646
se_73156669
stackoverflow
MACHINE_LEARNING
How can I get the inference compute graph of the PyTorch model?
How can I get the inference compute graph of the PyTorch model? I want to handwrite a framework to perform inference of a given neural network. The network is so complicated, so to make sure my implementation is correct, I need to know how exactly the inference process is done on the device. I tried to use torchviz to...
https://stackoverflow.com/questions/73156669/how-can-i-get-the-inference-compute-graph-of-the-pytorch-model
pytorch, onnx
1,659,027,933
se_79711939
stackoverflow
MACHINE_LEARNING
Difference between tokens generated on a configuration in two different contexts
Difference between tokens generated on a configuration in two different contexts I have a model that given a configuration, or state (of a Rubik's cube, but whatever, it is a sequence of integers) generates a movement (from 0 to 5). This movement can be used to bring the configuration to another state and the model ha...
https://stackoverflow.com/questions/79711939/difference-between-tokens-generated-on-a-configuration-in-two-different-contexts
python, pytorch, tensor, reinforcement-learning
1,753,276,095
se_61848635
stackoverflow
MACHINE_LEARNING
How to decide which mode to use for 'kaiming_normal' initialization
How to decide which mode to use for 'kaiming_normal' initialization I have read several codes that do layer initialization using nn.init.kaiming_normal_() of PyTorch. Some codes use the fan in mode which is the default. Of the many examples, one can be found here and shown below. init.kaiming_normal(m.weight....
https://stackoverflow.com/questions/61848635/how-to-decide-which-mode-to-use-for-kaiming-normal-initialization
initialization, pytorch
1,589,702,167
se_71608439
stackoverflow
MACHINE_LEARNING
Can PyTorch / XLA be used for the Coral dev board TPUs?
Can PyTorch / XLA be used for the Coral dev board TPUs? The last discussion of this I found was before [this article]https://cloud.google.com/blog/products/ai-machine-learning/pytorch-is-now-ga-on-google-cloud-tpus came out. Has anyone had any experience or know if it is possible to use a pytorch model directly on th...
https://stackoverflow.com/questions/71608439/can-pytorch-xla-be-used-for-the-coral-dev-board-tpus
pytorch, google-coral
1,648,150,453
se_68243122
stackoverflow
MACHINE_LEARNING
RuntimeError: Given groups=1, weight of size [64, 32, 3, 3], expected input[128, 64, 32, 32] to have 32 channels, but got 64 channels instead
RuntimeError: Given groups=1, weight of size [64, 32, 3, 3], expected input[128, 64, 32, 32] to have 32 channels, but got 64 channels instead I am trying to experiment with why we have a Vanishing & exploding gradient, and why Resnet is so helpful in avoiding the two problems above. So I decided to train a plain Convo...
https://stackoverflow.com/questions/68243122/runtimeerror-given-groups-1-weight-of-size-64-32-3-3-expected-input128
python, neural-network, pytorch
1,625,389,328
se_68319216
stackoverflow
MACHINE_LEARNING
AttributeError: 'numpy.ndarray' object has no attribute 'unsqueeze'
AttributeError: 'numpy.ndarray' object has no attribute 'unsqueeze' I'm running a training code using pyhtorch and numpy. This is the plot_example function: def plot_example(low_res_folder, gen): files=os.listdir(low_res_folder) gen.eval() for file in files: image=Image.open("t...
https://stackoverflow.com/questions/68319216/attributeerror-numpy-ndarray-object-has-no-attribute-unsqueeze
python-3.x, pytorch, numpy-ndarray
1,625,844,302
se_76595301
stackoverflow
MACHINE_LEARNING
import error with pyg-lib and torch-sparse
import error with pyg-lib and torch-sparse I have been facing an issue with importing torch_geometric, every-time I run, from torch_geometric.nn import MessagePassing I get a stack trace as follows - /Users/karan_bania/anaconda3/envs/PyGtut/lib/python3.10/site-packages/torch_geometric/typing.py:18: UserWarning: An i...
https://stackoverflow.com/questions/76595301/import-error-with-pyg-lib-and-torch-sparse
import, pytorch, cpu, pytorch-geometric
1,688,224,401
se_67518928
stackoverflow
MACHINE_LEARNING
How to make VScode launch.json for a Python module
How to make VScode launch.json for a Python module I'm researching self-supervised machine learning code. And I have wanted to debug the code with python debugger not pdb.set_trace(). This is python command for ubuntu terminal. python -m torch.distributed.launch --nproc_per_node=1 main_swav.py \ --data_path /dataset/i...
https://stackoverflow.com/questions/67518928/how-to-make-vscode-launch-json-for-a-python-module
python, visual-studio-code, pytorch, vscode-debugger
1,620,907,483
se_78994162
stackoverflow
MACHINE_LEARNING
How can I just calculate a part of grad using make_functional in PyTorch?
How can I just calculate a part of grad using make_functional in PyTorch? func_model, func_params = make_functional(self.model) def fm(x, func_params): fx = func_model(func_params, x) return fx.squeeze(0).squeeze(0) def floss(func_params,input): fx = fm(input...
https://stackoverflow.com/questions/78994162/how-can-i-just-calculate-a-part-of-grad-using-make-functional-in-pytorch
python, network-programming, deep-learning, pytorch, gradient-descent
1,726,577,824
se_79663445
stackoverflow
MACHINE_LEARNING
RuntimeError: expected scalar type Float but found BFloat16 with nn.TransformerEncoder
RuntimeError: expected scalar type Float but found BFloat16 with nn.TransformerEncoder I’m running my model in bf16-mixed precision and encountering the following error: RuntimeError: expected scalar type Float but found BFloat16 This happens when I apply an nn.TransformerEncoder model to my data. My input consists of...
https://stackoverflow.com/questions/79663445/runtimeerror-expected-scalar-type-float-but-found-bfloat16-with-nn-transformere
pytorch
1,749,727,705
se_79683781
stackoverflow
MACHINE_LEARNING
Getting StopIteration or No Output while using HuggingFace InferenceClient with TinyLlama / Falcon models
Getting StopIteration or No Output while using HuggingFace InferenceClient with TinyLlama / Falcon models I'm trying to run text generation using the Hugging Face InferenceClient in Python, but I keep getting either a StopIteration error or no output at all. Here's my setup: from huggingface_hub import InferenceClient...
https://stackoverflow.com/questions/79683781/getting-stopiteration-or-no-output-while-using-huggingface-inferenceclient-with
python, pytorch, huggingface-transformers, langchain, large-language-model
1,751,204,523
se_76844362
stackoverflow
MACHINE_LEARNING
50% training and test accuracy in deep nn model for binarily classifying 2d points
50% training and test accuracy in deep nn model for binarily classifying 2d points I have a deep neural network with 2 hidden layers. I'm trying to use the neural network to classify 2d datapoints to either 0 or 1. That data that I've generated looks like this: What I'm trying to do also looks like this tensorflow cl...
https://stackoverflow.com/questions/76844362/50-training-and-test-accuracy-in-deep-nn-model-for-binarily-classifying-2d-poin
python, pytorch, neural-network
1,691,294,374
se_78007663
stackoverflow
MACHINE_LEARNING
Pytorch reserving way more data than needed
Pytorch reserving way more data than needed I'm trying to finetune a sentencetransformer. The issue is that I'm running into an OOM-error (I'm using google-cloud to train the model). I keep getting that pytorch reserves ~13GB (theres ~14GB) available thus there's no room for any batch. If I try to calculate the actual...
https://stackoverflow.com/questions/78007663/pytorch-reserving-way-more-data-than-needed
python, memory, pytorch, sentence-transformers
1,708,089,874
se_73327697
stackoverflow
MACHINE_LEARNING
Configuring a progress bar while training for Deep Learning
Configuring a progress bar while training for Deep Learning I have this tiny training function upcycled from a tutorial. def train(epoch, tokenizer, model, device, loader, optimizer): model.train() with tqdm.tqdm(loader, unit="batch") as tepoch: for _,data in enumerate(loader, 0): y = data['target_ids'].to(dev...
https://stackoverflow.com/questions/73327697/configuring-a-progress-bar-while-training-for-deep-learning
python, pytorch, tqdm
1,660,259,140
se_79397100
stackoverflow
MACHINE_LEARNING
RuntimeError: Batching rule not implemented for aten::gru.input
RuntimeError: Batching rule not implemented for aten::gru.input I'm using torchrl for training my reinforcement learning agent. I'm trying to call a GRU layer with batched data (to be precise, calling a GAE as an advantage module with the batched data from the replay buffer), and it shows this error: RuntimeError: Ba...
https://stackoverflow.com/questions/79397100/runtimeerror-batching-rule-not-implemented-for-atengru-input
python, pytorch
1,738,161,634
se_79684873
stackoverflow
MACHINE_LEARNING
Model with ResNet blocks stuck at low accuracy
Model with ResNet blocks stuck at low accuracy I am trying to implement classification of ECG segments from PTB-XL database (https://physionet.org/content/ptb-xl/1.0.3/). The architecture of the model which I am using is: import torch import torch.nn as nn class ResNetBlock(nn.Module): def __init__(self, in_chann...
https://stackoverflow.com/questions/79684873/model-with-resnet-blocks-stuck-at-low-accuracy
python, pytorch, neural-network, conv-neural-network, resnet
1,751,291,422
se_79692554
stackoverflow
MACHINE_LEARNING
What's the use case for `torch.randn_like` when`requires_grad=True`?
What's the use case for `torch.randn_like` when`requires_grad=True`? In PyTorch, requires_grad can be set to True in torch.randn_like, what's the use case for this? Say we have $\epsilon ~ N(0, I)$, to my understanding, since $\epsilon$ is not a parameter, there is no need to pipe gradient through it. Thanks in ad...
https://stackoverflow.com/questions/79692554/whats-the-use-case-for-torch-randn-like-whenrequires-grad-true
python, pytorch
1,751,878,335
se_79695755
stackoverflow
MACHINE_LEARNING
How to get the KL divergence between two datasets (say ImageNet1k and FGVC-Aircraft)
How to get the KL divergence between two datasets (say ImageNet1k and FGVC-Aircraft) I want to find out the KL divergence between 2 datasets, so for that I am extracting the features from ResNet50 for both of them, but if I calculate the same for ImageNet1k (say 20% of val set) and FGVC-Aircraft test set, I get a very...
https://stackoverflow.com/questions/79695755/how-to-get-the-kl-divergence-between-two-datasets-say-imagenet1k-and-fgvc-aircr
python, deep-learning, pytorch
1,752,069,680
se_79697025
stackoverflow
MACHINE_LEARNING
Why is "with torch.cuda.stream()" not asynchronous?
Why is "with torch.cuda.stream()" not asynchronous? Cause I'm trying to achieve the overlap between the forward and backward passes of two model chunks in dualpipe. I plan to simply implement it using torch.cuda.stream first, as follows: def overlapped_forward_backward( module0: torch.nn.Module, inpu...
https://stackoverflow.com/questions/79697025/why-is-with-torch-cuda-stream-not-asynchronous
python, pytorch
1,752,148,802
se_79700340
stackoverflow
MACHINE_LEARNING
RendezvousTimeoutError when using torchrun
RendezvousTimeoutError when using torchrun I am attempting to do training with multiple GPUs on pytorch, but am experiencing a RendezvousTimeoutError when doing so. I have looked at the relevant documentation and forums, but have not solved the issue. Here are relevant details of what I am attempting: I am trying to u...
https://stackoverflow.com/questions/79700340/rendezvoustimeouterror-when-using-torchrun
machine-learning, pytorch
1,752,452,893
se_79656626
stackoverflow
MACHINE_LEARNING
How to install pytorch and opencv using a fixed conda channel order?
How to install pytorch and opencv using a fixed conda channel order? Conda creates a pristine environment, configures a fixed channel order, and then starts installing pytorch torchvisioni pytorch-cuda and opencv, and it prompts for dependency conflicts. Do I have to install opencv via pip? The same thing happens with...
https://stackoverflow.com/questions/79656626/how-to-install-pytorch-and-opencv-using-a-fixed-conda-channel-order
python, opencv, ffmpeg, pytorch, conda
1,749,261,379
se_53580088
stackoverflow
MACHINE_LEARNING
Calculate the output size in convolution layer
Calculate the output size in convolution layer How do I calculate the output size in a convolution layer? For example, I have a 2D convolution layer that takes a 3x128x128 input and has 40 filters of size 5x5.
https://stackoverflow.com/questions/53580088/calculate-the-output-size-in-convolution-layer
machine-learning, deep-learning, pytorch, conv-neural-network
1,543,752,568
se_79678471
stackoverflow
MACHINE_LEARNING
When using TensorDictPrioritizedReplayBuffer, should i store "td_error" field in TensorDict data?
When using TensorDictPrioritizedReplayBuffer, should i store "td_error" field in TensorDict data? Let's say you are gonna train DDPG or any algorithm that use Prioritized Replay Buffer. When using torchrl TensorDictPrioritizedReplayBuffer, after you calculate td_error, you gonna use it to call TensorDictPrio...
https://stackoverflow.com/questions/79678471/when-using-tensordictprioritizedreplaybuffer-should-i-store-td-error-field-in
pytorch, reinforcement-learning
1,750,826,401
se_69539538
stackoverflow
MACHINE_LEARNING
ERROR: vars() argument must have __dict__ attribute when trying to use trainer.train() on custom HF dataset?
ERROR: vars() argument must have __dict__ attribute when trying to use trainer.train() on custom HF dataset? I have the following model that I am trying to fine-tune (CLIP_ViT + classification head). Here’s my model definition: class CLIPNN(nn.Module): def __init__(self, num_labels, pretrained_name="openai/clip-v...
https://stackoverflow.com/questions/69539538/error-vars-argument-must-have-dict-attribute-when-trying-to-use-trainer-t
dictionary, machine-learning, pytorch, dataset, huggingface-transformers
1,634,037,123
se_79701808
stackoverflow
MACHINE_LEARNING
Piecewise curve segment lengths from Pytorch
Piecewise curve segment lengths from Pytorch Most examples of pdist (or cdist) seems to be between two tensors. If I have a piecewise curve defined as follows: line=torch.tensor([(-104.6400,0.0000),(-104.6400,0.1500),(-103.5500,0.5140),(-98.1000,1.0775),(-92.6500,1.4553)]) What I have coded to get the segment lengths...
https://stackoverflow.com/questions/79701808/piecewise-curve-segment-lengths-from-pytorch
python, pytorch
1,752,570,699
se_55920015
stackoverflow
MACHINE_LEARNING
How to realize a polynomial regression in Pytorch
How to realize a polynomial regression in Pytorch I want my neural network to solve a polynomial regression problem like y=(x*x) + 2x -3. So right now I created a network with 1 input node, 100 hidden nodes and 1 output node and gave it a lot of epochs to train with a high test data size. The problem is that the pred...
https://stackoverflow.com/questions/55920015/how-to-realize-a-polynomial-regression-in-pytorch
python, regression, pytorch, polynomial-approximations
1,556,624,019
se_79695488
stackoverflow
MACHINE_LEARNING
Trained Huggingface EncoderDecoderModel.generate() produces only bos-tokens
Trained Huggingface EncoderDecoderModel.generate() produces only bos-tokens I am working on a Huggingface transformers EncoderDecoderModel consisting of a frozen BERT-Encoder (answerdotai-ModernBERT-base) and a trainable GPT2-Decoder. Due to the different architectures for Encoder and Decoder, both come with different...
https://stackoverflow.com/questions/79695488/trained-huggingface-encoderdecodermodel-generate-produces-only-bos-tokens
python, deep-learning, pytorch, huggingface-transformers, large-language-model
1,752,058,070
se_79700988
stackoverflow
MACHINE_LEARNING
How TorchRL deals with multiple trajectories in the same batch?
How TorchRL deals with multiple trajectories in the same batch? I am trying to understand how the DQN algorithm with RNNs works in PyTorch's RL API through this tutorial. However, the way some of the classes handle episodes and batches during training are unclear to me. I noticed that SyncDataCollector stitches episod...
https://stackoverflow.com/questions/79700988/how-torchrl-deals-with-multiple-trajectories-in-the-same-batch
python, pytorch, reinforcement-learning
1,752,501,047
se_71582280
stackoverflow
MACHINE_LEARNING
RuntimeError: shape '[-1, 784]' is invalid for input of size 614400
RuntimeError: shape '[-1, 784]' is invalid for input of size 614400 I'm practicing code that implements the "Auto-Encoding Variable Bayes (VAE)" paper. However, the error "RuntimeError:shape [16, 1, 28, 28] is invalid for input of size 37632" has not been resolved. I don't know how to solve it. Please help me....
https://stackoverflow.com/questions/71582280/runtimeerror-shape-1-784-is-invalid-for-input-of-size-614400
python, pytorch, conv-neural-network, runtime-error, transformer-model
1,648,013,744
se_79697190
stackoverflow
MACHINE_LEARNING
ComfyUI error: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0
ComfyUI error: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0 I am trying to train a LoRA in ComfyUI using the modified version of the example workflow for ComfyUI-FluxTrainer (https://github.com/kijai/ComfyUI-FluxTrainer/issues) I found on reddit here (https://www.reddit...
https://stackoverflow.com/questions/79697190/comfyui-error-expected-all-tensors-to-be-on-the-same-device-but-found-at-least
python, pytorch
1,752,156,359
se_79700170
stackoverflow
MACHINE_LEARNING
Cannot install pytorch in Python
Cannot install pytorch in Python While installing pytorch in the terminal using $ pip install pytorch I get the following error Collecting pytorch Using cached pytorch-1.0.2.tar.gz (689 bytes) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-er...
https://stackoverflow.com/questions/79700170/cannot-install-pytorch-in-python
python, pytorch
1,752,431,033
se_79691715
stackoverflow
MACHINE_LEARNING
Can I use a custom attention layer while still leveraging a pre-trained BERT model?
Can I use a custom attention layer while still leveraging a pre-trained BERT model? In the paper “Using Prior Knowledge to Guide BERT’s Attention in Semantic Textual Matching Tasks”, they multiply a similarity matrix with the attention scores inside the attention layer. I want to apply a similar customization, but I a...
https://stackoverflow.com/questions/79691715/can-i-use-a-custom-attention-layer-while-still-leveraging-a-pre-trained-bert-mod
pytorch, nlp, huggingface-transformers, bert-language-model, transformer-model
1,751,802,422
se_79406168
stackoverflow
MACHINE_LEARNING
Code higher efficientnet models based on B0 model
Code higher efficientnet models based on B0 model I wanted to utilize EfficientNet models for my study. However, while I was able to construct EfficientNet-B0, I'm stuck on the part on expanding it to it's higher models - B1, B2, so on.. Here is my implementation of my code for B0: import torch import torch.nn as nn ...
https://stackoverflow.com/questions/79406168/code-higher-efficientnet-models-based-on-b0-model
deep-learning, pytorch, efficientnet
1,738,478,736
se_75833935
stackoverflow
MACHINE_LEARNING
Is there any way to specify a typehinted Pytorch DataLoader?
Is there any way to specify a typehinted Pytorch DataLoader? Say I have the following: class SomeClass: def some_function(dataloader: DataLoader): for idx, batch in enumerate(dataloader): ... do something with batch ... I would like to type the dataloader such that I can show through function par...
https://stackoverflow.com/questions/75833935/is-there-any-way-to-specify-a-typehinted-pytorch-dataloader
python, pytorch, python-typing, pytorch-dataloader
1,679,662,547
se_70986821
stackoverflow
MACHINE_LEARNING
ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch
ERROR: Could not find a version that satisfies the requirement torch (from versions: none) ERROR: No matching distribution found for torch I tried to download torch by using pip install torch I faced this problem: C:\Users\Ahmad Sadek>pip install torch ERROR: Could not find a version that satisfies the requirement tor...
https://stackoverflow.com/questions/70986821/error-could-not-find-a-version-that-satisfies-the-requirement-torch-from-versi
python, python-3.x, pytorch
1,643,979,683
se_76067578
stackoverflow
MACHINE_LEARNING
how can i download pytorch manually?
how can i download pytorch manually? hello im trying to use some python programs that need pytorch and when trying to install it using the command pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 this is the error i get WARNING: Retrying (Retry(total=4, connect=None, read=N...
https://stackoverflow.com/questions/76067578/how-can-i-download-pytorch-manually
python, pip, pytorch, download, package
1,682,018,567
se_78059837
stackoverflow
MACHINE_LEARNING
unable to implement tgt_mask and tgt_key_padding mask properly in transformer decoder model
unable to implement tgt_mask and tgt_key_padding mask properly in transformer decoder model I have implemented a transformer decoder for next token prediction. I am passing the tgt_mask and tgt_key_padding mask to not attend the future tokens and to ignore the padding. but I am constantly receiving the error Training ...
https://stackoverflow.com/questions/78059837/unable-to-implement-tgt-mask-and-tgt-key-padding-mask-properly-in-transformer-de
python, pytorch, nlp, transformer-model, attention-model
1,708,939,721
se_79210054
stackoverflow
MACHINE_LEARNING
import torch throws TypeError: can't set attributes of built-in/extension type 'torch._C.DisableTorchFunctionSubclass'
import torch throws TypeError: can&#39;t set attributes of built-in/extension type &#39;torch._C.DisableTorchFunctionSubclass&#39; I installed torch==1.13.0+cu116 and ran Python on the terminal. Then, I did import torch, but I got the following error: >>> import torch Traceback (most recent call last): File "<stdin>...
https://stackoverflow.com/questions/79210054/import-torch-throws-typeerror-cant-set-attributes-of-built-in-extension-type
python, pytorch
1,732,173,335
se_72226652
stackoverflow
MACHINE_LEARNING
I want train a set of weight using pytorch, but the weights do not even change
I want train a set of weight using pytorch, but the weights do not even change I want to reproduce a method from a paper, the code in this paper was written in tensorflow1.0 and I want to rewrite it in pytorch. A brief description, I want to get a set of G that can be used to reweight input data but in training, the G...
https://stackoverflow.com/questions/72226652/i-want-train-a-set-of-weight-using-pytorch-but-the-weights-do-not-even-change
tensorflow, pytorch
1,652,430,896
se_65822014
stackoverflow
MACHINE_LEARNING
RuntimeError: Input tensor at index 3 has invalid shape [2, 2, 16, 128, 64] but expected [2, 4, 16, 128, 64]
RuntimeError: Input tensor at index 3 has invalid shape [2, 2, 16, 128, 64] but expected [2, 4, 16, 128, 64] Runtime error while finetuning a pretrained GPT2-medium model using Huggingface library in SageMaker - ml.p3.8xlarge instance. The finetuning_gpt2_script.py contains the below, Libraries: from transformers impo...
https://stackoverflow.com/questions/65822014/runtimeerror-input-tensor-at-index-3-has-invalid-shape-2-2-16-128-64-but
python, pytorch, amazon-sagemaker, huggingface-transformers, gpt-2
1,611,209,478
se_78053086
stackoverflow
MACHINE_LEARNING
solving an ODE using neural networks
solving an ODE using neural networks I want to solve this ODE using neural nets. du/dt + 2u + t = 0 with initial condition u(0)=1 and t is between 0 to 2. I want to use pytorch and automatic differentiation method to solve this equation. but I don't know how can I calculate du/dt in pytorch. I want to define loss func...
https://stackoverflow.com/questions/78053086/solving-an-ode-using-neural-networks
pytorch, neural-network, ode, automatic-differentiation
1,708,791,411
se_63047762
stackoverflow
MACHINE_LEARNING
Correct way to register a parameter for model in Pytorch
Correct way to register a parameter for model in Pytorch I tried to define a simple model in Pytorch. The model computes negative log prob for a gaussian distribution: import torch import torch.nn as nn class GaussianModel(nn.Module): def __init__(self): super(GaussianModel, self).__init__() sel...
https://stackoverflow.com/questions/63047762/correct-way-to-register-a-parameter-for-model-in-pytorch
python, pytorch
1,595,483,772
se_75127947
stackoverflow
MACHINE_LEARNING
How predict next word using LSTM model?
How predict next word using LSTM model? I am currently building an LSTM model in Pytorch to predict the next word of a given input. My model: class LSTM(nn.Module): def __init__(self, vocab_size, embedding_dim, hidden_dim, num_layers, dropout_rate, tie_weights): super().__init__() self.num_layers = num_laye...
https://stackoverflow.com/questions/75127947/how-predict-next-word-using-lstm-model
python, pytorch, lstm
1,673,811,965
se_66217552
stackoverflow
MACHINE_LEARNING
How to assign NaN to tensor element?
How to assign NaN to tensor element? I want to assign NaN to a tensor element. import torch x = torch.tensor([1, 2, 3]) x[x == 2] = None I have the error: TypeError: can't assign a NoneType to a torch.LongTensor I need it to make sure that some later sophisticated calculations are not made for certain values of x.
https://stackoverflow.com/questions/66217552/how-to-assign-nan-to-tensor-element
python, pytorch, typeerror, nan, tensor
1,613,438,490
se_70159221
stackoverflow
MACHINE_LEARNING
RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead
RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead I wrote below code using PyTorch and ran into the runtime error: tns = torch.tensor([1,0,1]) tns.mean() --------------------------------------------------------------------------- RuntimeError ...
https://stackoverflow.com/questions/70159221/runtimeerror-mean-input-dtype-should-be-either-floating-point-or-complex-dty
python, pytorch, runtime-error, mean, tensor
1,638,208,668
se_79690376
stackoverflow
MACHINE_LEARNING
Pytorch C++ API doesn&#39;t load
Pytorch C++ API doesn&#39;t load I am testing a C++ API and trying to load the .pt files which trained in Python and saved there. My problem is that it stuck at loading it, in the exact this line module = torch::jit::load(model_path); (mode_path is string variable and is path to my .pt). I do not have graphics card an...
https://stackoverflow.com/questions/79690376/pytorch-c-api-doesnt-load
python, c++, pytorch
1,751,641,420
se_77994888
stackoverflow
MACHINE_LEARNING
Can we provide an example and motivation on when to use covariant and contravariant?
Can we provide an example and motivation on when to use covariant and contravariant? I have some troubles finding real use cases of covariant/contravariant. I would like a concrete motivation and example on when covariant/contravariant is used, in particular, I would appreciate the example to be such that if covariant...
https://stackoverflow.com/questions/77994888/can-we-provide-an-example-and-motivation-on-when-to-use-covariant-and-contravari
python, pytorch, python-typing, liskov-substitution-principle
1,707,919,622
se_79691807
stackoverflow
MACHINE_LEARNING
How to find MSE when using a batch loader?
How to find MSE when using a batch loader? I'm working on a regression task using deep learning models. While calculating the MSE, I have divided by the length of the dataset. However, ChatGPT is suggesting me to divide it by the length of the loader. What is the correct way to calculate MSE in this case? Also, I want...
https://stackoverflow.com/questions/79691807/how-to-find-mse-when-using-a-batch-loader
python, deep-learning, pytorch, eval, mse
1,751,810,199
se_74968093
stackoverflow
MACHINE_LEARNING
Most efficient way to use a large image dataset with Google Colab -- getting drive timeout + memory errors
Most efficient way to use a large image dataset with Google Colab -- getting drive timeout + memory errors I'm using Google Colab to a classifier in PyTorch and my training dataset has ~30,000 JPEG images which I have stored in my Google Drive. Efficiently using this large amount of data with Colab and Drive has been ...
https://stackoverflow.com/questions/74968093/most-efficient-way-to-use-a-large-image-dataset-with-google-colab-getting-dri
python, machine-learning, deep-learning, pytorch, google-colaboratory
1,672,471,083
se_79686864
stackoverflow
MACHINE_LEARNING
S3 Torchconnector loads data as a list of tensors
S3 Torchconnector loads data as a list of tensors I'm setting up a model and about to start training a dataset from an S3 bucket. To load the data from S3 I'm using s3torchconnector.S3MapDataset.from_prefix which loads the data into the Sagemaker space I'm using. However, when I start to training, this S3torchconnecto...
https://stackoverflow.com/questions/79686864/s3-torchconnector-loads-data-as-a-list-of-tensors
python, database, amazon-s3, pytorch, amazon-sagemaker
1,751,434,624
se_64980694
stackoverflow
MACHINE_LEARNING
Pytorch, opencv installation problem in python2 having cv library installed in python3
Pytorch, opencv installation problem in python2 having cv library installed in python3 I am running Python code on Ubuntu 18.04. I needed opencv library for the code so I installed opencv using python3: pip3 install opencv-python But the code requires and compatible with Python 2. I tried to install the library usin...
https://stackoverflow.com/questions/64980694/pytorch-opencv-installation-problem-in-python2-having-cv-library-installed-in-p
python, python-3.x, python-2.7, pytorch, ubuntu-18.04
1,606,195,504
se_78906762
stackoverflow
MACHINE_LEARNING
PyTorch TensorBoard SummaryWriter giving empty metrics
PyTorch TensorBoard SummaryWriter giving empty metrics I've been setting up tensorboard with PyTorch. Originally I was using lightning, and ran into an issue where I would log my hyperparameter, but the metrics in the HPARAMS tab would be empty. So, to pin point the issue I moved over to the simplest possible example ...
https://stackoverflow.com/questions/78906762/pytorch-tensorboard-summarywriter-giving-empty-metrics
python, tensorflow, pytorch, tensorboard, tensorboardx
1,724,430,047
se_79605098
stackoverflow
MACHINE_LEARNING
Cross-validation with PyTorch
Cross-validation with PyTorch I am trying to implement cross-validation with PyTorch; I am used to Sklearn's cross_validation function which is much simpler to use (most likely because I did not fully understand what was happening under the hood); I was hoping someone could advise if first of all this looks correct an...
https://stackoverflow.com/questions/79605098/cross-validation-with-pytorch
python, machine-learning, pytorch, cross-validation
1,746,305,389
se_58692476
stackoverflow
MACHINE_LEARNING
What is Adaptive Average Pooling and how does it work?
What is Adaptive Average Pooling and how does it work? I recently came across a method in Pytorch when I try to implement AlexNet. I don't understand how it works. Please explain the idea behind it (with some examples) and how it is different from Max Pooling or Average Pooling in terms of Neural Network functionality...
https://stackoverflow.com/questions/58692476/what-is-adaptive-average-pooling-and-how-does-it-work
python, math, neural-network, deep-learning, pytorch
1,572,866,793
se_79635390
stackoverflow
MACHINE_LEARNING
PyTorch and Streamlit interaction error: &quot;Tried to instantiate class &#39;__path__._path&#39;, but it does not exist!&quot;
PyTorch and Streamlit interaction error: &quot;Tried to instantiate class &#39;__path__._path&#39;, but it does not exist!&quot; I'm developing an application that uses Streamlit and PyTorch (through the huggingface transformers library) to analyze system requirements with a language model. However, I'm encountering t...
https://stackoverflow.com/questions/79635390/pytorch-and-streamlit-interaction-error-tried-to-instantiate-class-path
python, machine-learning, pytorch, huggingface-transformers, streamlit
1,747,998,374
se_71533654
stackoverflow
MACHINE_LEARNING
open and read PT. file using python code by pytorch
open and read PT. file using python code by pytorch I want to read a PT file with python and I don't know how, I want to open it with python can you help me please, any ideas?
https://stackoverflow.com/questions/71533654/open-and-read-pt-file-using-python-code-by-pytorch
python, pytorch
1,647,641,254
se_69429586
stackoverflow
MACHINE_LEARNING
How to get a Histogram of PyTorch tensors in batches?
How to get a Histogram of PyTorch tensors in batches? Is there a way to get the histograms of torch tensors in batches? For Example: x is a tensor of shape (64, 224, 224) # x will have shape of (64, 256) x = batch_histogram(x, bins=256, min=0, max=255)
https://stackoverflow.com/questions/69429586/how-to-get-a-histogram-of-pytorch-tensors-in-batches
python, pytorch, histogram, tensor
1,633,303,115
se_79674587
stackoverflow
MACHINE_LEARNING
PyTorch Lightning does not terminate on Mac OS Metal (M4 Max) when num_workers &gt; 0
PyTorch Lightning does not terminate on Mac OS Metal (M4 Max) when num_workers &gt; 0 I've been trying to train some basic models using PyTorch Lightning on an M4 Max Mac Studio. While the training itself goes without hitch, there appears to be a problem when attempting to terminate the program at the end. After train...
https://stackoverflow.com/questions/79674587/pytorch-lightning-does-not-terminate-on-mac-os-metal-m4-max-when-num-workers
python, pytorch, pytorch-lightning
1,750,522,674
se_59149138
stackoverflow
MACHINE_LEARNING
How do you invert a tensor of boolean values in Pytorch?
How do you invert a tensor of boolean values in Pytorch? With NumPy, you can do it with np.invert(array), but there's no invert function in Pytorch. Let's say I have a 2D tensor of boolean values: import torch ts = torch.rand((10, 4)) < .5 tensor([[ True, True, False, True], [ True, True, True, True], ...
https://stackoverflow.com/questions/59149138/how-do-you-invert-a-tensor-of-boolean-values-in-pytorch
python, python-3.x, machine-learning, deep-learning, pytorch
1,575,338,009
se_79681636
stackoverflow
MACHINE_LEARNING
GPU out of memory issue when training in PyTorch
GPU out of memory issue when training in PyTorch I am trying training data for my AI/ML model and got CUDA out of memory issue : Any solution would be the great help torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 3.52 GB. GPU 0 has a total capacity of 11.75 GB of which 609.19 MB is free. I...
https://stackoverflow.com/questions/79681636/gpu-out-of-memory-issue-when-training-in-pytorch
python, pytorch, gpu
1,751,013,277
se_55820303
stackoverflow
MACHINE_LEARNING
Fixing the seed for torch random_split()
Fixing the seed for torch random_split() Is it possible to fix the seed for torch.utils.data.random_split() when splitting a dataset so that it is possible to reproduce the test results?
https://stackoverflow.com/questions/55820303/fixing-the-seed-for-torch-random-split
pytorch, torch
1,556,058,995
se_79644970
stackoverflow
MACHINE_LEARNING
ERROR: Failed building wheel for mamba-ssm
ERROR: Failed building wheel for mamba-ssm Error Message: RuntimeError: The detected CUDA version (11.8) mismatches the version that was used to compile PyTorch (12.6). Please make sure to use the same CUDA versions. The complete log is shown at the end as follows: ERROR: Failed building wheel for mamba-ssm Failed to...
https://stackoverflow.com/questions/79644970/error-failed-building-wheel-for-mamba-ssm
pytorch, mamba-ssm
1,748,584,974
se_79676236
stackoverflow
MACHINE_LEARNING
What size should an `IterableDataset` report when used in a multi-worker `DataLoader`?
What size should an `IterableDataset` report when used in a multi-worker `DataLoader`? Here's a simple dataset and a data loader that uses it: import torch from torch.utils.data import DataLoader, IterableDataset class Dataset(IterableDataset): def __init__(self, size: int): super().__init__() se...
https://stackoverflow.com/questions/79676236/what-size-should-an-iterabledataset-report-when-used-in-a-multi-worker-datalo
python, pytorch, pytorch-dataloader
1,750,684,286
se_70621634
stackoverflow
MACHINE_LEARNING
TypeError: forward() got an unexpected keyword argument &#39;input_ids&#39;
TypeError: forward() got an unexpected keyword argument &#39;input_ids&#39; I have pre-trained BERT model with my head. I am using a fine-tuned Roberta Model that is unbiased-toxic-roberta trained on Jigsaw Data: https://huggingface.co/unitary/unbiased-toxic-roberta Creating the data using pytorch dataset tokenizer = ...
https://stackoverflow.com/questions/70621634/typeerror-forward-got-an-unexpected-keyword-argument-input-ids
python-3.x, pytorch, huggingface-transformers
1,641,560,329
se_72262608
stackoverflow
MACHINE_LEARNING
Steps for Machine Learning in Pytorch
Steps for Machine Learning in Pytorch When we define our model in PyTorch. We run through different #epochs. I want to know that in the iteration of epochs. What is the difference between the two following snippets of code in which the order is different? These two snippet versions are: I found over tutorials The cod...
https://stackoverflow.com/questions/72262608/steps-for-machine-learning-in-pytorch
python, machine-learning, pytorch
1,652,718,861
se_74057587
stackoverflow
MACHINE_LEARNING
How to export PyTorch model to file (Python) and load it (libtorch C++) using TorchScript?
How to export PyTorch model to file (Python) and load it (libtorch C++) using TorchScript? I am struggling with the (de)serialization of PyTorch data. I would like to save my model to a PT(H) file after training it with PyTorch (using GPU). Next I would like to load that serialized model in C++ context (using libtorch...
https://stackoverflow.com/questions/74057587/how-to-export-pytorch-model-to-file-python-and-load-it-libtorch-c-using-to
c++, serialization, pytorch, deserialization, libtorch
1,665,671,693
se_79674172
stackoverflow
MACHINE_LEARNING
PyTorch CUDA Out of Memory in Graph Generation
PyTorch CUDA Out of Memory in Graph Generation In my project I use pytorch to deploy a customed llm inference. In generation step I use torch.cuda.graph to reduce the CPU overhead since the implement of this llm is quite naive torch-version. In short I slice the total max output token length to several steps, each st...
https://stackoverflow.com/questions/79674172/pytorch-cuda-out-of-memory-in-graph-generation
pytorch, large-language-model
1,750,483,003
se_79641155
stackoverflow
MACHINE_LEARNING
CNN predicts constant values for sparse amplitude regression — can&#39;t learn true pixel values
CNN predicts constant values for sparse amplitude regression — can&#39;t learn true pixel values I’m training a small CNN (code below) to predict sparse amplitude maps from binary masks. Input: 60×60 image with exactly 15 pixels set to 1, rest are 0. Target: Same size, 0 everywhere except those 15 pixels, which have...
https://stackoverflow.com/questions/79641155/cnn-predicts-constant-values-for-sparse-amplitude-regression-cant-learn-true
tensorflow, machine-learning, deep-learning, pytorch, conv-neural-network
1,748,377,627
se_79638978
stackoverflow
MACHINE_LEARNING
Stable Diffusion WebUI Torch Installation Error: [WinError 32] File in Use by Another Process
Stable Diffusion WebUI Torch Installation Error: [WinError 32] File in Use by Another Process I'm trying to run Stable Diffusion WebUI (v1.10.1) on Windows using the built-in launch.py script. However, during the environment setup, it fails to install torch==2.1.2 and torchvision==0.16.2. Here are my environment detai...
https://stackoverflow.com/questions/79638978/stable-diffusion-webui-torch-installation-error-winerror-32-file-in-use-by-an
windows, pytorch, torch, torchvision, stable-diffusion
1,748,264,886
se_79671010
stackoverflow
MACHINE_LEARNING
Numpy function sum does not work on PyTorch tensors
Numpy function sum does not work on PyTorch tensors I am wondering if it is expected that if I call numpy.sum on a PyTorch tensor I get an error. As an aside, it does work on Pandas DataFrames. data = [[1.1, 2.2], [1.1, 2.2], [1.1, 2.2]] a = np.array(data) d = pd.DataFrame(data) t = torch.tensor(data) np.sum(a, axis...
https://stackoverflow.com/questions/79671010/numpy-function-sum-does-not-work-on-pytorch-tensors
python, numpy, pytorch, compatibility
1,750,264,048
se_69230570
stackoverflow
MACHINE_LEARNING
How to do batched dot product in PyTorch?
How to do batched dot product in PyTorch? I have a input tensor that is of size [B, N, 3] and I have a test tensor of size [N, 3] . I want to apply a dot product of the two tensors such that I get [B, N] basically. Is this actually possible?
https://stackoverflow.com/questions/69230570/how-to-do-batched-dot-product-in-pytorch
pytorch
1,631,923,631
se_79659212
stackoverflow
MACHINE_LEARNING
AttributeError: &#39;list&#39; object has no attribute &#39;to&#39; (samples are actually a Tensor)
AttributeError: &#39;list&#39; object has no attribute &#39;to&#39; (samples are actually a Tensor) EDIT: I'm training a model using a custom dataloader. The outcome from the dataloader is a list of tensors which cannot be processed by the main model because I have defined the sampler as samples = samples.to(device, n...
https://stackoverflow.com/questions/79659212/attributeerror-list-object-has-no-attribute-to-samples-are-actually-a-tens
python, machine-learning, pytorch, tensor, training-data
1,749,486,826
se_66992585
stackoverflow
MACHINE_LEARNING
How does one use Pytorch (+ cuda) with an A100 GPU?
How does one use Pytorch (+ cuda) with an A100 GPU? I was trying to use my current code with an A100 gpu but I get this error: ---> backend='nccl' /home/miranda9/miniconda3/envs/metalearningpy1.7.1c10.2/lib/python3.8/site-packages/torch/cuda/__init__.py:104: UserWarning: A100-SXM4-40GB with CUDA capability sm_80 is n...
https://stackoverflow.com/questions/66992585/how-does-one-use-pytorch-cuda-with-an-a100-gpu
python, machine-learning, neural-network, pytorch
1,617,822,268
se_79668219
stackoverflow
MACHINE_LEARNING
issues installing PyTorch in a new virtual environment
issues installing PyTorch in a new virtual environment I'm testing some models and have created virtual environments for them. One of them required PyTorch which I was able to install with no issues. However, for another one, I've made a new virtual environment and when installing flash-attn, it complains about missin...
https://stackoverflow.com/questions/79668219/issues-installing-pytorch-in-a-new-virtual-environment
python, pytorch, flash-attn
1,750,106,757
se_79618223
stackoverflow
MACHINE_LEARNING
PyTorch3D Build Fails with &quot;Cannot open include file: &#39;thrust/detail/cstdint.h&#39;&quot;
PyTorch3D Build Fails with &quot;Cannot open include file: &#39;thrust/detail/cstdint.h&#39;&quot; I'm trying to build PyTorch3D from source on Windows 11 using CUDA 12.8, but the build fails with the following error during the compilation of CUDA extensions: FAILED: D:/Project/3D_Reconstruction/src/pytorch3d/build/te...
https://stackoverflow.com/questions/79618223/pytorch3d-build-fails-with-cannot-open-include-file-thrust-detail-cstdint-h
python, machine-learning, deep-learning, pytorch, computer-vision
1,747,065,151
se_79662773
stackoverflow
MACHINE_LEARNING
How to transform a S3 directory as os.Path in Python with boto3?
How to transform a S3 directory as os.Path in Python with boto3? I want to use ImageFolder from Torchvision with an AWS S3 bucket where I have my dataset saved, however, it requires a os.Path like file and with boto3 I can just get a directory or a list which is not allowed by ImageFolder. Do you know how can I get a ...
https://stackoverflow.com/questions/79662773/how-to-transform-a-s3-directory-as-os-path-in-python-with-boto3
python, amazon-web-services, machine-learning, amazon-s3, pytorch
1,749,684,797
se_79662498
stackoverflow
MACHINE_LEARNING
How can I view the value of a LibTorch tensor in Visual Studio debugger
How can I view the value of a LibTorch tensor in Visual Studio debugger In the image below I am running the same PPO minimalist project. On the right side is the original code in python with PyTorch in VSCode. On the left side is the converted code in C++ with LibTorch in VS2022 Community Edition. The Python VSCode sh...
https://stackoverflow.com/questions/79662498/how-can-i-view-the-value-of-a-libtorch-tensor-in-visual-studio-debugger
c++, pytorch, libtorch
1,749,667,525
se_60667134
stackoverflow
MACHINE_LEARNING
How to visualize 3d joints of a SMPL model based on pose params
How to visualize 3d joints of a SMPL model based on pose params I am trying to use demo.py in nkolot / GraphCMR | GitHub. I am interested in obtaining joints from the inferred SMPL image and visualize it similar to described in README of this project: gulvarol / smplpytorch | GitHub. I also posted the issue here: http...
https://stackoverflow.com/questions/60667134/how-to-visualize-3d-joints-of-a-smpl-model-based-on-pose-params
deep-learning, computer-vision, pytorch
1,584,088,157
se_79666147
stackoverflow
MACHINE_LEARNING
PyTorch Sharing CUDA tensors
PyTorch Sharing CUDA tensors I have a question considering sharing gpu-tensors between processes using the torch.multiprocessing module. Here is a minimal example: import torch import torch.multiprocessing as mp from torch.nn import Embedding import time device = 'cuda' if torch.cuda.is_available() else 'cpu' def wor...
https://stackoverflow.com/questions/79666147/pytorch-sharing-cuda-tensors
pytorch, python-multiprocessing
1,749,934,586
se_72725944
stackoverflow
MACHINE_LEARNING
Create custom connection/ non-fully connected layers in Pytorch
Create custom connection/ non-fully connected layers in Pytorch As shown in the figure, it is a 3 layer with NN, namely input layer, hidden layer and output layer. I want to design the NN(in PyTorch, just the arch) where the input to hidden layer is fully-connected. However, from hidden layer to output, the first two ...
https://stackoverflow.com/questions/72725944/create-custom-connection-non-fully-connected-layers-in-pytorch
python, machine-learning, deep-learning, neural-network, pytorch
1,655,968,201
se_51054627
stackoverflow
MACHINE_LEARNING
PyTorch Autograd automatic differentiation feature
PyTorch Autograd automatic differentiation feature I am just curious to know, how does PyTorch track operations on tensors (after the .requires_grad is set as True and how does it later calculate the gradients automatically. Please help me understand the idea behind autograd. Thanks.
https://stackoverflow.com/questions/51054627/pytorch-autograd-automatic-differentiation-feature
python, machine-learning, computer-vision, pytorch
1,530,074,320
se_79653745
stackoverflow
MACHINE_LEARNING
Using Torchvison ImageFolder on AWS S3
Using Torchvison ImageFolder on AWS S3 I'm working with an AWS S3 instance and trying to deploy a SSL model loading a dataset from a bucket list I have defined on S3. The DL framework I'm using is PyTorch and more concretely to load the images dataset from S3 I'm using Torchvsion. However, when I try to load the image...
https://stackoverflow.com/questions/79653745/using-torchvison-imagefolder-on-aws-s3
amazon-web-services, amazon-s3, pytorch, amazon-sagemaker, torchvision
1,749,093,628
se_79641245
stackoverflow
MACHINE_LEARNING
Is it possible to save a Pytorch model and continue training the model later without needing the model class definition?
Is it possible to save a Pytorch model and continue training the model later without needing the model class definition? I am curious, as I have not found a way to save a Pytorch model and load the same model to continue training it on a new dataset without needing the original model definition. So far, I know how to ...
https://stackoverflow.com/questions/79641245/is-it-possible-to-save-a-pytorch-model-and-continue-training-the-model-later-wit
pytorch, neural-network
1,748,382,908