Questions tagged [pytorch]
For conceptual questions that somehow involve the PyTorch library, but note that programming questions are off-topic here.
113
questions with no upvoted or accepted answers
4
votes
3
answers
3k
views
What is the fundamental difference between max pooling and adaptive max pooling used in PyTorch
PyTorch provides max pooling and adaptive max pooling.
Both, max pooling and adaptive max pooling, is defined in three dimensions: 1d, 2d and 3d. For simplicity, I am discussing about 1d in this ...
3
votes
0
answers
269
views
Reverse Process in Diffusion Model Doesn't Return Original Image
I am attempting to program a Denoising Diffusion Model based on the one introduced in the article by Ho et al. (2020). However, I have run into issues while testing the reverse diffusion process.
...
3
votes
0
answers
118
views
How are partial derivatives calculated in a computational graph?
I am trying to understand how are partial derivatives calculated in a computational graph. I understand reasoning behind computational graphs and I am bold enough to say I understand how they work, at ...
2
votes
0
answers
141
views
Periodical fluctuations in loss curves
I am training a neural network (specifically a GRU based architecture but I think this is not too relevant for the question). My loss curves, especially the training loss but also the validation loss, ...
2
votes
0
answers
30
views
How to create a loss function that penalizes duplicate indices in the output tensor?
We're working on a sequence-to-sequence problem using pytorch, and are using cross-entropy to calculate the loss when comparing the output sequence to the target sequence. This works fine and ...
2
votes
0
answers
286
views
What is an "additional channel dimension" contain in batch normalization?
Consider the following explanations regarding batch normalization layers in PyTorch
#1: one dimensional batch normalization
class torch.nn.BatchNorm1d(.........)
Applies Batch Normalization over a 2D ...
2
votes
0
answers
649
views
Positional Encoding in Transformer on multi-variate time series data hurts performance
I set up a transformer model that embeds positional encodings in the encoder. The data is multi-variate time series-based data.
As I just experiment with the positional encoding portion of the code I ...
2
votes
0
answers
27
views
Is there any closed form analytical expression to represent fractional max pooling?
There are Nineteen types of pooling layers in PyTorch.
Almost all of the layers are provided with corresponding analytical formulae. But analytical formulae are not provided for the fractional max-...
2
votes
0
answers
428
views
Is there any animation that illustrates the "fold" and "unfold" operations of convolutional layers?
There are fourteen convolution layers in PyTorch. Among them six are related to convolution, another six are related to transposed convolution. The remaining two are fold and unfold operations.
The ...
2
votes
0
answers
263
views
How will the filter size affect the transpose convolution operation?
After a series of convolutions, I am up-sampling a compressed representation, I was curious what is the methodology I should follow to choose an optimum kernel size for up-sampling.
How will the ...
2
votes
0
answers
237
views
Why does GAN loss converge to log(2) and not -log(2)?
In Goodfellow's paper, he says:
Hence, by inspecting Eq. 4 at $D^*_G (\mathbf{x}) = \frac{1}{2}$, we find $C(G) = \log \frac{1}{2}+ \log \frac{1}{2} = − \log 4$. To see that this is the best ...
2
votes
0
answers
93
views
Why does the BatchNormalization layer produce different outputs during training and inference?
I modified resnet50 architecture to get a regression network. I just add batchnorm1d and ReLU layers just before the fully connected layer. During the training, the output of batchnorm1d layer is ...
2
votes
0
answers
269
views
Why is my variational auto-encoder generating random noise?
This is my first variational autoencoder. Background info: I am using the MNIST digits dataset. The model is created and trained in PyTorch. The model is able to get a reasonably low loss, but the ...
2
votes
0
answers
770
views
How can I train YOLO with the COCO dataset?
I am trying to implement the original YOLO architecture for object detection, but I am using the COCO dataset. However, I am a bit confused about the image sizes of COCO. The original YOLO was trained ...
1
vote
1
answer
91
views
Custom Loss Function Traps Network in Local Optima
I am working with a feedforward neural network to fit the following simple function:
N(1) = -1
N(2) = -1
N(3) = 1
N(4) = -1
But I don't want to use the Mean-...
1
vote
0
answers
21
views
Any tutorials/courses to learn variational autoencoders on tabular data?
I aim to use variational autoencoders (VAE) to find interpretable latent spaces for genetic data. So, I need to understand how they work, what activation function to use, etc. But all tutorials and ...
1
vote
1
answer
42
views
How to calculate the gradient for the output with respect to the input pixels
Hi for my project I'm using a somewhat simple CNN consisting of several convolution layers and pooling layers. Essentially the model is trained to perform a blur of sorts on an input image.
For my ...
1
vote
0
answers
33
views
Proper way to load a RL (reinforcement learning) model (pytorch) for "testing"...?
I'm working on a RL problem where, in a nutshell, an agent has to go from point A to point B, in that order, with as few steps as possible, using DQN with PyTorch, to train the agent.
During training, ...
1
vote
0
answers
36
views
What’s more efficient in multihead attention: multiply QKV by $W_i$ then split or linearly project QKV $h$ times into dimensions $d_k$?
I’m looking to bridge two implementations of multihead attention.
Approach 1: Multiply and Split
Each of the queries, keys, and values is multiplied by a separate square weight matrix of size (...
1
vote
0
answers
26
views
Why completely two different algorithms are being used in Deep Q Learning?
I'm a new student in reinforcement learning. Recently, I've been studying about different algorithms of RL. But I'm quite surprized that there are some algorithms which are named as "same" ...
1
vote
0
answers
18
views
re-use D(fake) for optimizing both, G and D when training GANs
When training GANs, I can do this:
pseudo code
opt_g = Optimizer(G.params)
opt_d = Optimizer(D.params)
...
1
vote
1
answer
173
views
How to make a model forget specific training it has received?
Does L1/L2 (NAdam weight decay) really make the model "unlearn"?
Ok so my question might be dumb but is there any way to "unlearn" a model - and yeah I know there is wieght_decay ...
1
vote
0
answers
361
views
Why feed forward neural network (FFN) in transformer block has a "contract and expand" pattern?
I noticed that in many (every ?) transformer architecture, the FFN (i.e the MLP network at the end of one transformer block) consists of two linear layers (with an activation) where the first layer ...
1
vote
0
answers
54
views
Integrated gradients on text to text models
I am trying to apply integrated gradients (using library captum) on a text generation model. Specifically, it is a model that generates patches for input buggy code. I want to know if applying the ...
1
vote
0
answers
496
views
Training/Fine Tuning LLaVa
We wanted to fine-tune LLaVa model on some custom set of images. I wanted to know the Dataset format required for training and then finetuning.
1
vote
0
answers
266
views
Diffusion Model Failing to Learn
I'm trying to train a diffusion model to map between paired embedding spaces - ie using a CLIP text embedding to predict a CLIP image embedding. I have a working baseline model that predicts the ...
1
vote
2
answers
79
views
How to Represent Boardless Board Game as Input to RL Model?
I am currently doing my thesis project by creating an Imitation Learning (IL) agent that learns to play the board game Hive, which lacks a traditional 2D board. Pieces are placed relative to one ...
1
vote
0
answers
1k
views
Relation between Batch Size and Micro Batch Size
In distributed training of large models (pipeline parallelism), a mini batch of training samples is divided into n-micro batches. Each device performs forward and backward passes for a micro batch.
...
1
vote
0
answers
102
views
Why would increasing layers in PyTorch Transformer significantly increase loss?
I have a simple torch.nn.Transformer module for machine translation on the Multi30k dataset. It performs pretty well (32.2 Bleu score) but I looked at scaling up ...
1
vote
0
answers
39
views
dropout as the final layer or in every layer to avoid underfitting/overfitting
I am training a Dense neural network where I am having input as a 3x3 matrix, and predicting the eigenvalues of that matrix. Initially, I was having num_samples = 2000, so my model was not able to ...
1
vote
0
answers
229
views
What is wrong with my PyTorch model training on CIFAR10?
I am training a ResNet model on CIFAR10 dataset. For the training subset, I selected a random 1% of the train data from the default train/test split. For the test subset I used the whole default test ...
1
vote
0
answers
242
views
Higher validation loss after using Dropout
I’m working on a classification problem (500 classes). My NN has 3 fully connected layers, followed by an LSTM layer. I use nn.CrossEntropyLoss() as my loss ...
1
vote
0
answers
436
views
Where can I get Imagenet test dataset labels for evaluation
I have the imagenet train, validation and test set. I have been able to assign each image in the validation set into its respective class folders with the help of some online resources. However, for ...
1
vote
0
answers
165
views
How is it possible to use batches of data from within the same sequence with an LSTM?
ETA: More concise wording: Why do some implementations use batches of data taken from within the same sequence? Does this not make the cell state useless?
Using the example of an LSTM, it has a hidden ...
1
vote
0
answers
180
views
How can I produce crossbred images out of two datasets?
I'm very new to AI and deep learning. So my question is going to be very basic.
I'm trying to understand which approach I would need to use to cross-breed set of images. Let's say I'm having dataset ...
1
vote
0
answers
176
views
How to compute the loss for a sequence labeling task without the Softmax distribution?
For a sequence labeling task (NER), we compute the loss by passing the softmax distribution of the classes (e.g. vocabulary) with the gold label to the loss function (...
1
vote
0
answers
118
views
Are there any benefits of adding attention to linear layers?
Is attention useful only in transformer/convolution layers? Can I add it to linear layers? If yes, how (on a conceptual level, not necessarily the code to implement the layers)?
1
vote
1
answer
3k
views
Deep Q-Learning with multiple discrete actions
I am working on a DQN project with Pytorch, where I should choose multiple discrete actions, each in a range, say, (0, 15). I am wondering how I can model it, such ...
1
vote
0
answers
76
views
Batch normalization for multiple datasets?
I am working on a task of generating synthetic data to help the training of my model. This means that the training is performed on synthetic + real data, and tested on real data.
I was told that batch ...
1
vote
0
answers
649
views
Is there any gain by lazy initialization of weights, biases and number of input channels for a convolution operation?
The basic layers for performing convolution operations 1,2,3 in PyTorch are
...
1
vote
0
answers
77
views
What's the best way to take a list of lists as DQN input?
I have my own environment for the DQN algorithm. In my environment, the state space is represented by a list of lists, where each sublist can be of different lengths. In my case, the length of the ...
1
vote
0
answers
668
views
Why does the VAE using a KL-divergence with a non-standard mean does not produce good images?
I know I can make a VAE do generation with a mean of 0 and std-dev of 1.
I tested it with the following loss function:
...
1
vote
0
answers
371
views
variational auto encoder loss goes down but does not reconstruct input. out of debugging ideas
My variational autoencoder seems to work for MNIST, but fails on slightly "harder" data.
By "fails" I mean there are at least two apparent problems:
Very poor reconstruction, for ...
1
vote
0
answers
38
views
is it ok to take random actions while training a3c as in below code
i am trying to train an A3C algorithm but I am getting same output in the multinomial function.
can I train the A3C with random actions as in below code.
can someone expert comment.
...
1
vote
0
answers
118
views
Is it good practice to save NLP Transformer based pre-trained models into file system in production environment
I have developed a multi label classifier using BERT. I'm leveraging Hugging Face Pytorch implementation for transformers.
I have saved the pretrained model into the file directory in dev environment. ...
1
vote
0
answers
381
views
Classification or regression for deep Q learning
DQN implemented at https://github.com/PacktPublishing/PyTorch-1.x-Reinforcement-Learning-Cookbook/blob/master/Chapter07/chapter7/dqn.py uses the mean square error loss function for the neural network ...
1
vote
0
answers
79
views
In layman's terms, what is stochastic computation graph?
I'm going through the distributions package on PyTorch's documentation and came across the term stochastic computation graph. In layman's terms, what is it?
1
vote
0
answers
90
views
Benchmarking SAC on Pybullet
So far I have seen TD3 and DDPG benchmarks on Pybullet environments, but I am looking for SAC benchmarks on Pybullet too, anyone can help?
1
vote
0
answers
240
views
How can I use GPT-2 to modify seed text of one form into a different form (LENGTH INVARIANT) whilst retaining meaning?
I am currently starting a research project whereby I am trying to convert text of one form into another.
i.e. If I were to write a seed sentance of the form "Scientists have finally achieved the ...
1
vote
0
answers
403
views
Replace epsilon greedy action selection and the standard DQN by an Independent Gaussian Noise Network Model
Here is my code
Recently, I solved the game of Atari Breakout using a classic DQN model. The convergence of the mean reward slowly improved during three days. I was interested in learning a method ...