category
stringclasses
107 values
title
stringlengths
15
179
question_link
stringlengths
59
147
question_body
stringlengths
53
33.8k
answer_html
stringlengths
0
28.8k
__index_level_0__
int64
0
1.58k
loss function
What is the definition of the hinge loss function?
https://ai.stackexchange.com/questions/26330/what-is-the-definition-of-the-hinge-loss-function
<p>I came across the hinge loss function for training a neural network model, but I did not know the analytical form for the same.</p> <p>I can write the mean squared error loss function (which is more often used for regression) as</p> <p><span class="math-container">$$\sum\limits_{i=1}^{N}(y_i - \hat{y_i})^2$$</span><...
<p>The hinge loss/error function is the typical loss function used for <strong>binary classification</strong> (but it can also be extended to multi-class classification) in the context of <strong>support vector machines</strong>, although it can also be used in the context of neural networks, as described <a href="http...
212
loss function
How do I interpret this loss function?
https://ai.stackexchange.com/questions/36709/how-do-i-interpret-this-loss-function
<p>In this <a href="https://www.deeplearning.ai/ai-notes/optimization/" rel="nofollow noreferrer">AI note</a> from <a href="https://deeplearning.ai" rel="nofollow noreferrer">https://deeplearning.ai</a>, the loss function below is used for a regression problem. However, I don't know how to interpret this loss function....
<p>This is the sum of squared residuals, and it uses notation from the mathematical subfield of linear algebra (arguably functional analysis).</p> <p>The double vertical bars indicate that we use the mathematical operation of a <a href="https://en.wikipedia.org/wiki/Norm_(mathematics)" rel="nofollow noreferrer">norm</a...
213
loss function
Which loss function to choose for imbalanced datasets?
https://ai.stackexchange.com/questions/23653/which-loss-function-to-choose-for-imbalanced-datasets
<p>For imbalanced datasets (either in the context of computer vision or NLP), from what I learned, it is good to use a weighted log loss. However, in competitions, the people who are in top positions are not using weighted loss functions, but treating the classification problem as a regression problem, and using MSE as...
214
loss function
What is loss function in Neural Networks?
https://ai.stackexchange.com/questions/38905/what-is-loss-function-in-neural-networks
<p>I've been studying NNs with tensorflow and decided to code a simple NN from scratch to get a better idea on hwo they work.</p> <p>It my understanding that the cost is used in backpropagation, so basically you calculate the error between prediction and actual and backpropagate from there.</p> <p>However, in all the e...
<p>I think you are confused about the terms <em>error</em>, <em>loss function</em> and <em>metric</em>.</p> <p>To summarize:</p> <ol> <li>Error (vector) tells us how off each prediction is.</li> <li>Loss function maps the error (vector) to a single number (loss).</li> <li>Loss and metric (scalar) describes overall how ...
215
loss function
Does regularization just mean using an augmented loss function?
https://ai.stackexchange.com/questions/28855/does-regularization-just-mean-using-an-augmented-loss-function
<p>We need to use a loss function for training the neural networks.</p> <p>In general, the loss function depends only on the desired output <span class="math-container">$y$</span> and actual output <span class="math-container">$\hat{y}$</span> and is represented as <span class="math-container">$L(y, \hat{y})$</span>.</...
<p>Regularization is not limited to methods like L1/L2 regularization which are specific versions of what you showed.</p> <p>Regularization is any technique that would prevent network from overfitting and help network to be more generalizable to unseen data. Some other techniques are Dropout, Early Stopping, Data Augme...
216
loss function
How to implement loss function of H-GAN model
https://ai.stackexchange.com/questions/16101/how-to-implement-loss-function-of-h-gan-model
<p>I was trying to implement the loss function of <a href="https://yanweifu.github.io/papers/hairstyle_v_14_weidong.pdf" rel="nofollow noreferrer">H-GAN</a>. Here is my <a href="http://codepad.org/9C3Vac25" rel="nofollow noreferrer">code </a>. But it seem somethings wrong, maybe is recognition loss on z (EQ 9). I used...
217
loss function
Loss Function for Binary Classification with Multiple Correct Choices
https://ai.stackexchange.com/questions/37453/loss-function-for-binary-classification-with-multiple-correct-choices
<p>I have a binary classification problem, where there are multiple correct predictions, however, I would consider the prediction to be correct if the highest confidence prediction of a 1 is correct.</p> <p>I have had limited success with a CNN using the Hinge loss function. I think the reason is that, this loss functi...
218
loss function
How to check whether my loss function is convex or not?
https://ai.stackexchange.com/questions/29963/how-to-check-whether-my-loss-function-is-convex-or-not
<p>Loss functions are useful in calculating loss and then we can update the weights of a neural network. The loss function is thus useful in training neural networks.</p> <p>Consider the following excerpt from <a href="https://ai.stackexchange.com/questions/28877/what-are-the-necessary-mathematical-properties-to-be-a-l...
<p>It is the same as other functions. You can use Theorem 2 in <a href="https://www.princeton.edu/%7Eaaa/Public/Teaching/ORF523/S16/ORF523_S16_Lec7_gh.pdf" rel="nofollow noreferrer">this lecture</a> (from Princeton University):</p> <p><a href="https://i.sstatic.net/AL3yc.png" rel="nofollow noreferrer"><img src="https:/...
219
loss function
Generating 5 numbers with 1 input before loss function
https://ai.stackexchange.com/questions/17473/generating-5-numbers-with-1-input-before-loss-function
<p>I am trying make an ANN model that takes a constant m (will be changed later but now it is just a constant, let's say 0) as an input and generate 5 non-integer numbers (a1,a2..a5) after some layers like relu, linear,relu ... and then these 5 numbers enter to the loss function layer along with an additional 5 numbers...
220
loss function
What loss function to use when labels are probabilities?
https://ai.stackexchange.com/questions/11816/what-loss-function-to-use-when-labels-are-probabilities
<p>What loss function is most appropriate when training a model with target values that are probabilities? For example, I have a 3-output model. I want to train it with a feature vector <span class="math-container">$x=[x_1, x_2, \dots, x_N]$</span> and a target <span class="math-container">$y=[0.2, 0.3, 0.5]$</span>. <...
<p>Actually, the <a href="https://en.wikipedia.org/wiki/Cross_entropy" rel="noreferrer">cross-entropy</a> loss function would be appropriate here, since it measures the &quot;distance&quot; between a distribution <span class="math-container">$q$</span> and the &quot;true&quot; distribution <span class="math-container">...
221
loss function
How to transform a loss function into a score function?
https://ai.stackexchange.com/questions/41933/how-to-transform-a-loss-function-into-a-score-function
<p>Loss_Function/Maximize_Function/Score_Function, CustomLoss, pytorch. Using Custom Loss for Maximizing Score in PyTorch</p> <p>I'm using a PyTorch model with an LSTM input layer, a linear hidden layer, and 3 neurons in the output layer with a softmax activation function.</p> <p>Instead of using a loss function (such ...
<p>I suspect you could be reinventing the wheel a little bit here, because some of the description of what this task is <em>for</em> appears to match to a Reinforcement Learning (RL) scenario. You may find if you research approaches using neural networks to solve RL problems, that you get a lot of insight into things t...
222
loss function
What loss function will be correlated with classification metrics?
https://ai.stackexchange.com/questions/37176/what-loss-function-will-be-correlated-with-classification-metrics
<p>Recently I developed a custom training algorithm for deep learning models, based on evolutionary algorithms. Details are not important, except that it also uses decreasing regular cross entropy loss as its fitness function.</p> <p>What I observed is that it very well decreases the loss function but the classificatio...
<p>Different metrics measure different quantities, so there is no reason to expect different metrics to move together unless one is a function of the other (such as MSE and RMSE).</p> <p>Further, metrics like accuracy use thresholds that can prove problematic, versus evaluating the probability outputs directly. This is...
223
loss function
Comparing and studying Loss Functions
https://ai.stackexchange.com/questions/10025/comparing-and-studying-loss-functions
<p>I have a Deep Feedforward Neural Network <span class="math-container">$F: W \times \mathbb{R}^d \rightarrow \mathbb{R}^k$</span> (where <span class="math-container">$W$</span> is the space of the weights) with <span class="math-container">$L$</span> hidden layers, <span class="math-container">$m$</span> neurones per...
<p>Let's first express a network of arbitrary topology and heterogeneous or homogeneous cell type arrangements as</p> <p><span class="math-container">$$ N(T, H, s) := \, \big[\, \mathcal{Y} = F(P_s, \, \mathcal{X}) \,\big] \\ s \in \mathbb{C} \; \land \; s \le S \; \text{,} $$</span></p> <p>where <span class="math...
224
loss function
Custom Tensorflow loss function that disincentivizes all black pixels
https://ai.stackexchange.com/questions/33924/custom-tensorflow-loss-function-that-disincentivizes-all-black-pixels
<p>I'm training a Tensorflow model that receives an image and segments the image into foreground and background. That is, if the input image is <code>w x h x 3</code>, then the neural network outputs a <code>w x h x 1</code> image of <code>0</code>'s and <code>1</code>'s, where <code>0</code> represents background and ...
<p>The background being an unbalance class is a well known problem in image segmentation. Before digging into custom losses you should take a look to existing ones that address this specific issue like the <a href="https://pycad.co/the-difference-between-dice-and-dice-loss/" rel="nofollow noreferrer">Dice Loss</a> or <...
225
loss function
Deduce properties of the loss functions from the training loss curves
https://ai.stackexchange.com/questions/17376/deduce-properties-of-the-loss-functions-from-the-training-loss-curves
<p>I have two convex, smooth loss functions to minimise. During the training (a very simple model) using batch SGD (with tuned optimal learning rate for each loss function), I observe that the (log) loss curve of the loss 2 converges much faster and is much more smooth than that of the loss 2, as shown in the figure.</...
226
loss function
Which loss functions for transforming a density function to another density function?
https://ai.stackexchange.com/questions/13251/which-loss-functions-for-transforming-a-density-function-to-another-density-func
<p>I am looking at a problem which can be distilled as follows: I have a phenomenon which can be modeled as a probability density function which is "messy" in that it sums to unity over its support but is somewhat jagged and spiky, and does not correspond to any particular textbook function. It takes considerable amo...
227
loss function
Loss function that penalizes errors more at low values
https://ai.stackexchange.com/questions/47698/loss-function-that-penalizes-errors-more-at-low-values
<p>I am training Deep Learning models to predict the Remaining Useful Life (RUL) of certain devices. The RUL is an estimate of the time remaining until the device is expected to fail. Accurate predictions are especially critical when the RUL is low, as you have little time of reaction to plan maintenance or mitigate po...
<p>Taking the logarithm of the RUL is a possibility. That puts the interpretation in terms of percent. Then missing by one at a low value is a large percentage miss, while missing by one at a high value is a small percentage miss that will not be penalized as severely by square loss or absolute loss.</p> <p>Note that t...
228
loss function
Loss function decays linearly in segmentation MRI fascia
https://ai.stackexchange.com/questions/24674/loss-function-decays-linearly-in-segmentation-mri-fascia
<p>I am working on a segmentation of MRI images of the thigh. I am trying to segment the fascia, there is a slight imbalance between the background and the mask. I have about 1400 images from 30 patients for training and 200 for validation. I am working with keras. The loss function is combination of weighted cross ent...
229
loss function
Using conditional probability as an estimate in a loss function
https://ai.stackexchange.com/questions/46182/using-conditional-probability-as-an-estimate-in-a-loss-function
<p>I have a rather large ML framework that takes multiple conditional probability terms that are computed via classifiers/neural networks. This arbitrary loss function is computed via a function:</p> <pre><code>loss_value = arbitrary_loss(probability1, probability2, ..., P(Y|Z)) </code></pre> <p>I wish to have an <stro...
<p>your question is rather vague. A trained classifier should already estimate conditional probability of Y given input Z.</p> <p>if your question is how to train such a classifier the answer is via CrossEntropy loss. so you have the output probability from your (untrained) classifier network and also the grountruth. C...
230
loss function
How to understand marginal loglikelihood objective function as loss function (explanation of an article)?
https://ai.stackexchange.com/questions/8487/how-to-understand-marginal-loglikelihood-objective-function-as-loss-function-ex
<p>I am reading article <a href="https://allenai.org/paper-appendix/emnlp2017-wt/" rel="nofollow noreferrer">https://allenai.org/paper-appendix/emnlp2017-wt/</a> <a href="http://ai2-website.s3.amazonaws.com/publications/wikitables.pdf" rel="nofollow noreferrer">http://ai2-website.s3.amazonaws.com/publications/wikitable...
<p>I cannot answer your question but I am stuck in a similar rabbit hole so hopefully these references can help you.</p> <p>The loss function you are describing would be 0-1 loss. However, 0 would be the if our output matches and 1 would be if it does not. This function is not smooth and not convex. Thus we often repla...
231
loss function
Impact of scaling in loss terms when loss function is a composition of multiple functions
https://ai.stackexchange.com/questions/43522/impact-of-scaling-in-loss-terms-when-loss-function-is-a-composition-of-multiple
<p>I am training a deep learning model, the loss function of which is of the form</p> <p><span class="math-container">$$ \cal{L} = \cal{L_1} + \cal{L_2} $$</span></p> <p>where <span class="math-container">$\cal{L_1}$</span> and <span class="math-container">$\cal{L_2}$</span> are of very different orders. WLOG, let's as...
<ol> <li>not generally, consider a case where <span class="math-container">$L_2 = 1/L_1$</span>, if one converges to 0, the other one diverges</li> <li>Yes, that's the usual definition of convergence, though the &quot;<span class="math-container">$\approx$</span>&quot; is not really well defined usually</li> <li>exactl...
232
loss function
Loss function for choosing a subset of objects
https://ai.stackexchange.com/questions/20531/loss-function-for-choosing-a-subset-of-objects
<p>I'm trying to train a neural net to choose a subset from some list of objects. The input is a list of objects <span class="math-container">$(a,b,c,d,e,f)$</span> and for each list of objects the label is a list composed of 0/1 - 1 for every object that is in the subset, for example <span class="math-container">$(1,...
<p>The choice of the loss function depends primarily on the type of task you're tackling: classification or regression. Your problem is clearly a classification one since you have classes to which a given input can either belong or not. More specifically, what you're trying to do is multi-label classification, which is...
233
loss function
How to interpret a large variance of the loss function?
https://ai.stackexchange.com/questions/13862/how-to-interpret-a-large-variance-of-the-loss-function
<p>How do I interpret a large variance of a loss function?</p> <p>I am currently training a transformer network (using the software, but not the model from GPT-2) from scratch and my loss function looks like this: <a href="https://i.sstatic.net/LvhRs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LvhRs...
234
loss function
In logistic regression, why is the binary cross-entropy loss function convex?
https://ai.stackexchange.com/questions/28288/in-logistic-regression-why-is-the-binary-cross-entropy-loss-function-convex
<p>I am studying logistic regression for binary classification.</p> <p>The loss function used is <strong>cross-entropy</strong>. For a given input <span class="math-container">$x$</span>, if our model outputs <span class="math-container">$\hat{y}$</span> instead of <span class="math-container">$y$</span>, the loss is g...
<p>The <span class="math-container">$L_{CE}$</span> that you provided is binary cross-entropy, the factor <span class="math-container">$y$</span> and <span class="math-container">$(1-y)$</span> is because <span class="math-container">$y$</span> is binary <span class="math-container">$({0,1})$</span>, careful with the n...
235
loss function
Non-Convex Loss Function in Deep Learning Is a Big Deal?
https://ai.stackexchange.com/questions/4271/non-convex-loss-function-in-deep-learning-is-a-big-deal
<p>I want to use deep learning to estimate the value of a function based on some data. However, the loss function would be neither convex nor concave. Can I know if it is a big deal in deep learning? Is training a deep network, when loss function is convex, the same as optimizing a convex problem or not? I would be tha...
<p><strong>Optimization</strong></p> <p>In optimization, the loss function (sometimes called the error function) is a function that aggregates the disparity between actual and ideal behavioral states in multiple dimensions and over a sequence of input cases. In re-entrant (reinforced) learning, a feedback scalar or v...
236
loss function
How do I calculate the gradient of the hinge loss function?
https://ai.stackexchange.com/questions/8281/how-do-i-calculate-the-gradient-of-the-hinge-loss-function
<p>With reference to the research paper entitled <a href="https://ieeexplore.ieee.org/document/7296633" rel="nofollow noreferrer">Sentiment Embeddings with Applications to Sentiment Analysis</a>, I am trying to implement its sentiment ranking model in Python, for which I am required to optimize the following hinge loss...
<p>Hinge loss is difficult to work with when the derivative is needed because the derivative will be a piece-wise function. <code>max</code> has one non-differentiable point in its solution, and thus the derivative has the same. This was a very prominent issue with non-separable cases of SVM (and a good reason to use r...
237
loss function
Should softmax be in the model or in the loss function?
https://ai.stackexchange.com/questions/39648/should-softmax-be-in-the-model-or-in-the-loss-function
<p>Suppose I have an image segmentation model with an output of <code>[ 128, 128, 2 ]</code>, segmenting an input image into 2 parts.</p> <p>Commonly, loss functions have the sigmoid or softmax needed to produce a probability distribution in the loss function itself, for example:</p> <pre><code>tf.nn.sigmoid_cross_entr...
<p>Mathematically it does not matter at all. The results will be the same. However there is a strong reason to prefer it being in the loss function: numeric stability.</p> <p>Because the loss function knows more information (ie what the loss is), it can compute the softmax and loss together using some tricks to improve...
238
loss function
Which loss function should I use for binary classification?
https://ai.stackexchange.com/questions/13256/which-loss-function-should-i-use-for-binary-classification
<p>I plan to create a neural network using Python, Keras, and TensorFlow. All the tutorials I have seen so far are concerned with image recognition. However, the goal of my program would be to take in 10+ inputs and calculate a binary output (true/false) instead.</p> <p>Which loss function should I use for my task?</p>...
<p>There are several loss functions that you can use for binary classification. For example, you could use the <a href="https://en.wikipedia.org/wiki/Cross_entropy" rel="nofollow noreferrer"><strong>binary cross-entropy</strong></a> or the <a href="https://en.wikipedia.org/wiki/Hinge_loss" rel="nofollow noreferrer"><st...
239
loss function
DQN Loss function - doubt about stochastic approximation
https://ai.stackexchange.com/questions/42239/dqn-loss-function-doubt-about-stochastic-approximation
<p>In Deep Q Learning algorithm the convergence is generally achieved using smart tricks like the target network and the replay buffer.</p> <p>However there is one thing which is not clear to me. When the Q network is trained through SGD, the loss function is an expectation over all possible states, which is approximat...
<p>DQN is a off-policy method, this means that you are fine (apart from some variance factor) with sampling data from another distribution</p> <p>However, Replay Buffer have a state distribution that is different from the new policy one, which might create some problem</p> <p>SGD on the other hand, with such method, ha...
240
loss function
Constraining the output value range of a CNN independent of the loss function
https://ai.stackexchange.com/questions/4398/constraining-the-output-value-range-of-a-cnn-independent-of-the-loss-function
<p>I'm having the following problem: `</p> <p>I'm training a multi-output CNN and using the relative values of the outputs in my loss function. The net is learning well, but as the absolute values of the outputs are not regularized in anyway in the loss function, the values of the outputs keep rising. This causes a si...
<p>You can limit the absolute values of the outputs by "punishing" large values in the loss function. This is done by adding an extra term to the loss function. </p> <p>For example, if your existing loss function is <em>L(yhat, y)</em> where <em>yhat</em> is the output and <em>y</em> the correct value, create a new lo...
241
loss function
When should I create a custom loss function?
https://ai.stackexchange.com/questions/16022/when-should-i-create-a-custom-loss-function
<p>I'm using a neural network to solve a multi regression problem because I'm trying to predict continuous values. To be more specific, I'm making a tracking algorithm to track the position of an object, I'm trying to predict two values, the latitude and longitude of an object.</p> <p>Now, to calculate the loss of the ...
<p>Using two value and using MSE is probably a better approach. I'd you combine the value to one value, like the case of summation, the network may fits to output 0 on one axis and the value on the other. The method you propose also have the same issue. There are many combination to the real distance, but only one is c...
242
loss function
Loss function not able to capture the maxima of probability distribution
https://ai.stackexchange.com/questions/40482/loss-function-not-able-to-capture-the-maxima-of-probability-distribution
<p>I am trying to predict noise (random gaussian) with the help of a neural network. I am implementing a L2 loss (torch.nn.function.mse_loss) for computing the loss function between the prediction distribution and input distribution (random gaussian). Any suggestions on what I may do to correct this?</p> <p><strong>1. ...
<p>Gaussian noise is usually 0-mean, meaning that <em>it cancels out</em> on average especially with a squared loss (e.g. MSE): so your approach won't work.</p> <p>I think that you should instead <em>predict the mean and variance</em> of such noise distribution: in such a way you could handle noises that are not 0-cent...
243
loss function
What should I think about when designing a custom loss function?
https://ai.stackexchange.com/questions/35850/what-should-i-think-about-when-designing-a-custom-loss-function
<p>I'm trying to get my toy network to learn a sine wave.</p> <p>I output (via tanh) a number between -1 and 1, and I want the network to minimise the following loss, where <code>self(x)</code> are the predictions.</p> <pre><code>loss = -torch.mean(self(x)*y) </code></pre> <p>This should be equivalent to trading a stoc...
<p>It doesn't matter that your loss is not convex. As a matter of fact, the loss function of a neural network is in general neither convex nor concave (<a href="https://stats.stackexchange.com/questions/106334/cost-function-of-neural-network-is-non-convex">reference</a>).</p> <p>As ImotVoksim points out, the issue is t...
244
loss function
What are the necessary mathematical properties to be a loss function in gradient based optimizations?
https://ai.stackexchange.com/questions/28877/what-are-the-necessary-mathematical-properties-to-be-a-loss-function-in-gradient
<p>Loss functions are used in training neural networks.</p> <p>I am interested in knowing the mathematical properties that are necessary for a loss function to <strong>participate in gradient descent optimization</strong>.</p> <p>I know some <em>possible</em> candidates that may decide whether a function can be a loss ...
<p><strong>Summary:</strong> the loss needs to be differentiable, with some caveats.</p> <hr /> <p>I will introduce some notation, which I hope is clear: if not I am happy to clarify.</p> <p>Consider a neural network with parameters <span class="math-container">$\theta \in \mathbb{R}^d$</span>, which is usually a vecto...
245
loss function
Why do we use gradient descent to minimize the loss function?
https://ai.stackexchange.com/questions/36195/why-do-we-use-gradient-descent-to-minimize-the-loss-function
<p>The purpose of training neural networks is to minimize a loss function, in this process we usually use gradient descent method.</p> <p>But in Calculus, if we want to find the global minimum of a multivariable function, we usually first calculate the partial derivatives of this function with respect to its variables,...
<blockquote> <p>and then set these partial derivatives to zeros</p> </blockquote> <p>but how do you do that? This is analytically possible in very simple cases, such as least squares on linear regression. In that case, it's possible to invert the function and explicitly build the weight matrix and the biases.</p> <p>Bu...
246
loss function
how to use contrastive loss function for multi label classification?
https://ai.stackexchange.com/questions/48047/how-to-use-contrastive-loss-function-for-multi-label-classification
<p>I have a multi label classification problem, where I was initially using a binary cross entropy loss and my labels are one hot encoded. I found a paper similar to my application and have used contrastive loss function, but I am not sure how to use it in my code. I came across an implementation of supervised contrast...
247
loss function
Why am I getting spikes in the values of the loss function during training?
https://ai.stackexchange.com/questions/10764/why-am-i-getting-spikes-in-the-values-of-the-loss-function-during-training
<p>I trained a neural network on the <a href="https://www.unsw.adfa.edu.au/unsw-canberra-cyber/cybersecurity/ADFA-NB15-Datasets/" rel="nofollow noreferrer">UNSW-NB15 dataset</a>, but, during training, I am getting spikes in the loss function. The algorithms see part of this UNSW dataset a single time. The loss function...
<p>The spikes could be caused by many reasons: insufficient model capacity, incorrect label, buggy input parsing, ... Finding out the culprit requires some detective work. For instance, you could apply the learned model to the whole train set and manually examine the datapoints which result in the highest loss. Alterna...
248
loss function
Autoencoder for semi-supervised anomaly detection - a choice of loss function, scaler and activation function
https://ai.stackexchange.com/questions/47443/autoencoder-for-semi-supervised-anomaly-detection-a-choice-of-loss-function-s
<p>I am trying to build an autoencoder for semi-supervised anomaly detection on an intrusion detection dataset (CICIDS2017). The dataset has data with very wide range (like between 0 and 1+08).</p> <p>I am struggling with choosing a combination of scaler, final layer activation function, and loss function.</p> <p>What ...
249
backpropagation
Parallelize Backpropagation - How to synchronize the weights of each thread?
https://ai.stackexchange.com/questions/30418/parallelize-backpropagation-how-to-synchronize-the-weights-of-each-thread
<p>I implemented a parallel backpropagation algorithm that uses <span class="math-container">$n$</span> threads. Now every thread gets <span class="math-container">$\dfrac{1}{n}$</span> examples of the training data and updates its instance of the net with it. After every epoch the different threads share their updated...
<p>After a whole epoch, with multiple update steps, the neural networks in each thread will have diverged in a way where it may not make sense to take means of the weights. Ideally you should be combining data for each update step. In turn that means you will want to avoid making updates on every example, because the o...
250
backpropagation
Is it possible to reverse engineer out the loss based on weights update when data is unknown?
https://ai.stackexchange.com/questions/38308/is-it-possible-to-reverse-engineer-out-the-loss-based-on-weights-update-when-dat
<p>Assume the gradient updates (both <span class="math-container">$W_t$</span> and <span class="math-container">$W_{t+1}$</span>) and learning rate are known while data <span class="math-container">$X$</span> is unknown, is it possible to deduce the loss <span class="math-container">$L$</span> used in backprop algorith...
<p>First, there is no way you could recover the exact loss. At best you could recover the loss up to a constant factor, because the gradient is only giving information on the slope on the loss and not the actual loss values.</p> <p>If we make assumptions like a standard model architecture, and we have access to the mod...
251
backpropagation
How would I use backpropagation with a changing cost function
https://ai.stackexchange.com/questions/40059/how-would-i-use-backpropagation-with-a-changing-cost-function
<p>I have a neural network that is being trained with a changing cost function. Could I use backpropagation at all? If yes, how would I do this?</p>
<p>There is nothing wrong with changing your cost/loss function after every step while training a neural network. For example, this paper looks at a weight decay scheduler (which changes the weight regularization at every step): <a href="https://arxiv.org/abs/2006.08643" rel="nofollow noreferrer">https://arxiv.org/abs/...
252
backpropagation
Back propagation activation function derivative
https://ai.stackexchange.com/questions/37968/back-propagation-activation-function-derivative
<p>I am reading about backpropagation for fully connected neural networks and I found a very interesting <a href="https://www.jeremyjordan.me/neural-networks-training/" rel="nofollow noreferrer">article</a> by Jeremy Jordan. It explains the process from start to finish. There is a section though that confused me a bit....
<p>The author is rather free with changing from row to column format. The main philosophy or framework seems to be to implement the directions of &quot;forward&quot; evaluation and &quot;backwards&quot; gradient differentiation in the left-right direction, in diagrams as well as in formulas.</p> <p>However, this philos...
253
backpropagation
what is the backpropagation formula to calculate delta and update weights?
https://ai.stackexchange.com/questions/42447/what-is-the-backpropagation-formula-to-calculate-delta-and-update-weights
<p>I'm trying to study how backpropagation works step by step in a MultiLayer Perceptron neural network. I would really like to be able to understand how these calculations work. And I have a specific question I would like to ask. The formulas <strong>I'm trying to learn are the following to calculate the delta, and...
<p>Your understanding appears correct. One formula I want to nitpick about though, is that of the delta calculation for the hidden layer. I would suggest framing it as :</p> <pre><code>SUM of (delta * connection weight ) * derivative </code></pre> <p>rather than :</p> <pre><code>(SUM of delta * connection weight ) * de...
254
backpropagation
About the requirement to compute the gradient at layer $l$
https://ai.stackexchange.com/questions/40727/about-the-requirement-to-compute-the-gradient-at-layer-l
<p>I'm trying to understand a line of my note.</p> <p>Let's say there is a simple feedforward neural network that has <span class="math-container">$N$</span> layers, and for a given layer <span class="math-container">$l$</span>, it has weight <span class="math-container">$W^l$</span>, and <span class="math-container">$...
<blockquote> <ol> <li>A sub-expression <span class="math-container">$\delta^l$</span>, which is the gradient of the weighted output of the current layer <span class="math-container">$l$</span>, i.e. <span class="math-container">$\nabla_{z^l}C$</span>. (there is no such symbol in the link, but I believe my usage is corr...
255
backpropagation
How does BackProp avoid bias for the last input used for training?
https://ai.stackexchange.com/questions/46239/how-does-backprop-avoid-bias-for-the-last-input-used-for-training
<p>Here's a BackProp Algo definition from <a href="https://ujjwalkarn.me/2016/08/09/quick-intro-neural-networks/" rel="nofollow noreferrer">here</a>:</p> <blockquote> <p>Initially all the edge weights are randomly assigned. For every input in the training dataset, the ANN is activated and its output is observed. This o...
<p>The concern you've raised touches on the method of training known as online learning or <a href="https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Iterative_method" rel="nofollow noreferrer">stochastic gradient descent (SGD)</a>, where weights are updated after each individual training example. It's a common...
256
backpropagation
Does this article make use of the chain rule? And where?
https://ai.stackexchange.com/questions/42722/does-this-article-make-use-of-the-chain-rule-and-where
<p><strong>References:</strong></p> <ul> <li><strong>Chain rule in Wikipedia:</strong> <a href="https://en.wikipedia.org/wiki/Chain_rule" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Chain_rule</a></li> <li><strong>Chain rule in Towards Data Science:</strong> <a href="https://towardsdatascience.com/understan...
<p>Unless the derivation has been added in a comment, when you read code implementations of backpropagation, then the chain rule has already been used to derive the update rules. As it is basically a rule about multiplying one simpler derivative by another to resolve the derivative of a more complex function, then typi...
257
backpropagation
Please, could someone help me understand if the backpropagation explanations in these two articles about calculate the error are equivalent?
https://ai.stackexchange.com/questions/42626/please-could-someone-help-me-understand-if-the-backpropagation-explanations-in
<p>I have a question about backpropagation, I'm a beginner, I'm studying the formulas to calculate the delta of neurons, there are several sources on the internet, which teach in different ways, so I'm confused about the formulas presented in the explanations, as they are a little different. Please, could someone help ...
<p>The difference you spotted is only cosmetic when dealing with formulas yet both are equivalent. In general for any delta rule ultimately driven by some form of error be it primitive correction or Widrow-Hoff/LMS like SGD correction follows the three multiplicative terms (learning rate, error, input) format of your 2...
258
backpropagation
I need help understanding general back propagation algorithm
https://ai.stackexchange.com/questions/22238/i-need-help-understanding-general-back-propagation-algorithm
<p>In section 6.5.6 of the book <a href="https://www.deeplearningbook.org" rel="nofollow noreferrer">Deep Learning</a> by Ian et. al. general backpropagation algorithm is described as:</p> <blockquote> <p>The back-propagation algorithm is very simple. To compute the gradient of some scalar z with respect to one of its ...
259
backpropagation
Using features extracted from a CNN as convolutional filter
https://ai.stackexchange.com/questions/8664/using-features-extracted-from-a-cnn-as-convolutional-filter
<p>I'm a bit confused about this. Assume I have a CNN network with two branches:</p> <ol> <li>Top</li> <li>Bottom</li> </ol> <p>The top branch outputs a feature vector of shape 1x1x1x10 (batch, h, w, c) The bottom branch outputs a feature vector of shape (1, 10, 10, 10).</p> <p>I want to use the top feature vector a...
260
backpropagation
Class of functional equations that backpropagation can solve
https://ai.stackexchange.com/questions/20715/class-of-functional-equations-that-backpropagation-can-solve
<p>There is a theorem that states that basically a neural network can approximate any function whatsoever. However, this does not mean that it can solve any equation. I have some notes where it states that backpropagation allows us to solve problems of the following kind </p> <p><span class="math-container">$$ F(x_i, ...
261
backpropagation
Are there relatively new research papers that describe how to make back-propagation more efficient?
https://ai.stackexchange.com/questions/26986/are-there-relatively-new-research-papers-that-describe-how-to-make-back-propagat
<p>I read Yann LeCun's paper <a href="https://www.researchgate.net/publication/2811922_Efficient_BackProp" rel="nofollow noreferrer">Efficient BackProp</a>, which was published in 2000. I looked for similar but more recent papers on <a href="https://arxiv.org/" rel="nofollow noreferrer">Arxiv</a>, but I have not yet fo...
<p><a href="https://arxiv.org/pdf/2004.06093.pdf" rel="nofollow noreferrer">Here</a> is a paper that explains why ReLU rules.</p> <p>What we want is to disentangle data of different classes. In order to do that, we need a discontinuous mapping for the data. ReLU easily allows for that. It is even better than LeakyReLU,...
262
backpropagation
What kind of algorithm is the Levenberg–Marquardt algorithm?
https://ai.stackexchange.com/questions/2520/what-kind-of-algorithm-is-the-levenberg-marquardt-algorithm
<p>Is a Levenberg–Marquardt algorithm a type of back-propagation algorithm or is it a different category of algorithm?</p> <p>Wikipedia says that it is a curve fitting algorithm. How is a curve fitting algorithm relevant to a neural net?</p>
<p>In the context of Neural Networks, Backpropagation (with Gradient Descent, to use its full name) and Levengerg Marquardt are both members of the broader family of gradient descent algorithms. Backpropagation itself is not gradient descent, but it does the gradient climbing portion of a broader gradient descent algor...
263
backpropagation
Simple three layer neural network with backpropagation is not approximating tanh function
https://ai.stackexchange.com/questions/18762/simple-three-layer-neural-network-with-backpropagation-is-not-approximating-tanh
<p>I have this simple neural network in Python which I'm trying to use to aproximation tanh function. As inputs I have x - inputs to the function, and as outputs I want tanh(x) = y. I'm using sigmoid function also as an activation function of this neural network. </p> <pre><code>import numpy # scipy.special for the si...
<p>This is because of <strong>Vanishing Gradient Problem</strong></p> <p>What is Vanishing Gradient Problem ?</p> <p>when we do Back-propagation i.e moving backward in the Network and calculating gradients of loss(Error) with respect to the weights , the gradients tends to get smaller and smaller as we keep on moving...
264
backpropagation
Why doesnt my Neural Network work?
https://ai.stackexchange.com/questions/2588/why-doesnt-my-neural-network-work
<p>I Build this NN in c++. I reviewed it since 3 days. I checked every line 100 times, but I cant find my error. If someone can please help me find the Bugs: 1. The output is garbage 2. The weights go from 2e^79 down to -1.8e^80 after approximatly 400 iterations.</p> <pre><code>mat flip(mat m) { mat out(m.n_cols,m...
<p>A little search on Google answers your question.</p> <p>XOR input space is not linearly separable. It means that you cannot separate the input points in a 2D space into 1 area and 0 area by simply drawing a line between them. It requires at least 2 lines to separate the XOR input space and consequently 2 output node...
265
backpropagation
CNN: Difficulties understanding backward pass derivatives
https://ai.stackexchange.com/questions/32271/cnn-difficulties-understanding-backward-pass-derivatives
<p>I have really quite hard difficulties to understand what is actually going on in the backward pass of a CNN.</p> <p>I am currently focusing on these references:</p> <ol> <li><a href="https://towardsdatascience.com/forward-and-backward-propagations-for-2d-convolutional-layers-ed970f8bf602" rel="nofollow noreferrer">h...
266
backpropagation
How to train a CNN
https://ai.stackexchange.com/questions/7527/how-to-train-a-cnn
<p>When it comes to CNNs, I don't understand 2 things in the training process:</p> <ol> <li><p>How do I pass the error back when there are pooling layers between the convolutional layers?</p></li> <li><p>And if I know how it's done, can I train all the layers just like layers in normal Feed Forward Neural Nets?</p></l...
<p>Yes. You can train end-to-end. The introduction of convolution kernels with associated pooling layers to the sequence of forward feed operations on the signals does not change the basic principles.</p> <ul> <li>Gradient descent estimates the incremental change required to converge on an optimal behavior.</li> <li...
267
backpropagation
Why is my neural network giving me wildly incorrect error and not changing accuracy?
https://ai.stackexchange.com/questions/15970/why-is-my-neural-network-giving-me-wildly-incorrect-error-and-not-changing-accur
<p>My full code is as follows. I have tried to whittle it down to just the code that matters, but the problem I have is that i'm not sure what part of my network code is producing the problem. I've removed my code that loads and sifts through the CSV data because then my code would be too long.</p> <pre><code>#include...
<p>This is a guess, as I am not reading all that code!</p> <blockquote> <p>This was previously working when the error I fed back through backprop was just the difference between the correct result and the prediction. But I've since been told that I should be propagating back the Loss Functions error, which I then im...
268
backpropagation
Is there some kind of &quot;weighted maximum&quot; that allows the gradients to backpropagate?
https://ai.stackexchange.com/questions/35494/is-there-some-kind-of-weighted-maximum-that-allows-the-gradients-to-backpropag
<p>I was wanting to add a maximum in my neural network, but this seems a bad thing to do since it kills the gradients to all but one of the inputs.</p> <p>Is there some kind of &quot;weighted maximum&quot; that allows the gradients to backpropagate?</p> <p>Edit: I had a two dimensional tensor (correlation matrix) I wan...
<p>The maximum function is not smooth, since it's first derivative is not continuous.</p> <p>Having non-smooth functions is generally a bad thing for neural networks, since they don't work nicely with gradient decent.</p> <p>So what you want is a smooth approximation to these functions.</p> <p>Logsumexp is the smooth a...
269
backpropagation
In a neural network&#39;s neuron that has no activation function, to calculate the delta for the neuron during back propagation do you use a derivative?
https://ai.stackexchange.com/questions/36594/in-a-neural-networks-neuron-that-has-no-activation-function-to-calculate-the-d
<p>I have a neural network that is composed of an input layer, two hidden layers and an output layer. The topology is [151, 200, 100, 1] I am using ReLU activation function on the neurons that are in the hidden layers and no activation function on the neuron that is in the output layer. I am wondering if when calculati...
<p>Having no activation function means your activation function is the identity, namely <span class="math-container">$g(z)=z$</span>.</p> <p>Therefore, any derivative of <span class="math-container">$g(z)$</span> wrt to a parameter is simply the corresponding derivative of <span class="math-container">$z$</span>, with ...
270
backpropagation
How to test if my implementation of back propagation neural Network is correct
https://ai.stackexchange.com/questions/2727/how-to-test-if-my-implementation-of-back-propagation-neural-network-is-correct
<p>I am working on an implementation of the back propagation algorithm. What I have implemented so far seems working but I can't be sure that the algorithm is well implemented, here is what I have noticed during training test of my network:</p> <p>Specification of the implementation:</p> <ul> <li>A data set containin...
<p>Actually the implementation was correct, </p> <p>The source of the problem that causes a big error and really slow learning was the architecture of the neural network it self, the ANN has 7 hidden layers which causes the vanishing gradient problem.</p> <p>When I have decreased the ANN layers to 3 the cost of error...
271
backpropagation
What would an implementation of this Neural Network look like?
https://ai.stackexchange.com/questions/3971/what-would-an-implementation-of-this-neural-network-look-like
<p>I'm relatively new to neural networks and was wondering what an implementation of <a href="https://www.researchgate.net/profile/Bing_Zhao23/publication/271546169_Study_on_NNPID-based_adaptive_control_for_electro-optical_gyro_stabilized_platform/links/56e745f408ae438aab881bab.pdf" rel="noreferrer">this paper</a> woul...
<p>In the paper there is a diagram of the network showing how there are 3 outputs which share features but have their own set of associated weights. Back propagation works by only looking at one output at a time. <a href="https://i.sstatic.net/b1ywu.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/b1ywu....
272
backpropagation
Am I able to visualize the differentiation in backprop as follows?
https://ai.stackexchange.com/questions/9190/am-i-able-to-visualize-the-differentiation-in-backprop-as-follows
<p>I'm wondering if I can visualize the backprop process as follows (please excuse me if I have written something terrible wrong). If the loss function <span class="math-container">$L$</span> on a neural network represents the function has the form <span class="math-container">$$L = f(g(h(\dots u(v(\dots))))$$</span> ...
<p>Yes, a neural network plus loss function can be viewed as a function composition as you have written, and back propagation is just the chain function repeated. Your equations <span class="math-container">$L = f(g(h(\dots u(v(\dots))))$</span> and <span class="math-container">$\frac{\partial L}{\partial v} = \frac{\p...
273
backpropagation
How to perform back propagation with different sized layers?
https://ai.stackexchange.com/questions/20053/how-to-perform-back-propagation-with-different-sized-layers
<p>I'm developing my first neural network, using the well known MNIST database of handwritten digit. I want the NN to be able to classify a number from 0 to 9 given an image.</p> <p>My neural network consists of three layers: the input layer (784 neurons, each one for every pixel of the digit), a hidden layer of 30 ne...
<p>I'm not familiar with python I'm afraid, but I'll give a go at presenting some of the maths...</p> <p>In order to perform the <strong>back propagation</strong> using matrices, matrix <a href="https://en.wikipedia.org/wiki/Transpose" rel="nofollow noreferrer">transpose</a> is used for different sized layers. Also no...
274
backpropagation
What do symmetric weights mean and how does it make backpropagation biologically implausible?
https://ai.stackexchange.com/questions/35449/what-do-symmetric-weights-mean-and-how-does-it-make-backpropagation-biologically
<p>I was reading a paper on alternatives to backpropagation as a learning algorithm in neural networks. In <a href="https://arxiv.org/pdf/1609.01596.pdf" rel="nofollow noreferrer">this paper</a>, the author talks about the disadvantages of backpropagation, and one of the disadvantages stated is that backpropagation req...
<p>&quot;Symmetric weights&quot; means that the same weight value associated to a pair of nodes must be used during the forwards and backwards steps.</p> <p>The reason it makes back propagation biologically impossible in its naive formulation is that neurons fire electrical signals in only one direction, from the dendr...
275
backpropagation
Is my neural network working?
https://ai.stackexchange.com/questions/37297/is-my-neural-network-working
<p>I recently just finished programming a neural network in c#, and it seems like it's working. My question is if I'm doing it right. It's a very confusing process so I will explain.</p> <p>Basically every neuron in the network has a bias (except the first layer) and fully connected weights to the next. every neuron al...
<p>Unfortunately I highly doubt anyone is going to check your code or exact implementation as that is a very time consuming process. Luckily for you though, you don't need someone to check, you can check it yourself with <strong>gradient checking</strong>! The basic process is to manually calculate the exact gradient f...
276
backpropagation
Does the output of LLM&#39;s affect their neural weights?
https://ai.stackexchange.com/questions/41253/does-the-output-of-llms-affect-their-neural-weights
<p>When an LLM creates an output, it seemingly has no way to check if its output was valid. Therefore it wouldn't be able to back-propagate any changes to the weights is used to create that output.</p> <p>Right now, I suspect that all weight modification is done by training on input data, as that can (generally) be as...
<p>I will base my answer on GPT-2, as most LLMs are not too different in their architecture.</p> <p>The output of the transformer in an LLM is not text or tokens; it is a categorical distribution over the space of next possible tokens.</p> <p>To calculate loss of the transformer, you (commonly) take negative log likeli...
277
backpropagation
How does backpropagation know which weights to change?
https://ai.stackexchange.com/questions/31945/how-does-backpropagation-know-which-weights-to-change
<p>I'm currently working on constructing a neural network from scratch (in JavaScript). I'm in the middle of working on the backpropagation, but there's something I don't understand: how does the backprop algorithm know which weights to change or which paths to take? The way I did it, it always took all of the paths/we...
<p>@serali is correct, there are many resources to describe this process. I'm going to talk about it in a very general way.</p> <p><strong>Disclaimer</strong>: this is a work in progress, it is not yet complete.</p> <p><strong>Question</strong>:<br /> How do we know what weights to change in the network?</p> <p><stron...
278
backpropagation
In multilayer perceptron neural networks, are the names &quot;delta&quot;, &quot;gradient&quot; and &quot;error&quot; all the same thing? or not?
https://ai.stackexchange.com/questions/42633/in-multilayer-perceptron-neural-networks-are-the-names-delta-gradient-and
<p><strong>What is the difference between &quot;delta&quot;, &quot;gradient&quot; and &quot;error&quot;, are these names the same thing?</strong></p> <p>I'm confused because someone once told me that both the names &quot;delta&quot; and &quot;error&quot; are commonly used. And I searched the internet, and some explanat...
<p>The terms &quot;error&quot;, &quot;delta&quot; and &quot;gradient&quot; in neural network back-propagation are often used as shorthand, or loose explanations for the same thing. This is not strictly correct in all cases, and you should be careful to check the code in context. However, these words do make for suitabl...
279
backpropagation
If I manually trained a multilayer percetron neural network, always following exactly the same steps meticulously, would I always get the same result?
https://ai.stackexchange.com/questions/42776/if-i-manually-trained-a-multilayer-percetron-neural-network-always-following-ex
<p><strong>Reference:</strong> <a href="https://home.agh.edu.pl/%7Evlsi/AI/backp_t_en/backprop.html" rel="nofollow noreferrer">https://home.agh.edu.pl/~vlsi/AI/backp_t_en/backprop.html</a></p> <p>If I trained a multilayer percetron neural network manually, following exactly the backpropagation steps described in the ar...
<p>Unless you use full batch gradient descent method for your BP algo which is very rare in practice mainly due to its inefficiency and slow convergence, the usual <a href="https://en.wikipedia.org/wiki/Stochastic_gradient_descent#Iterative_method" rel="nofollow noreferrer">stochastic</a> or mini-batch or momentum-base...
280
backpropagation
Why in one article to calcule the delta uses the weights of current layer, while in another article uses the weights of neuron inputs of next layer?
https://ai.stackexchange.com/questions/42884/why-in-one-article-to-calcule-the-delta-uses-the-weights-of-current-layer-while
<p><strong>Article 1:</strong> <a href="https://pyimagesearch.com/2021/05/06/backpropagation-from-scratch-with-python/" rel="nofollow noreferrer">https://pyimagesearch.com/2021/05/06/backpropagation-from-scratch-with-python/</a></p> <p><strong>Article 2:</strong> <a href="https://machinelearningmastery.com/implement-ba...
<p>The key idea of <a href="https://en.wikipedia.org/wiki/Backpropagation" rel="nofollow noreferrer">backpropagation</a> can be summarized as:</p> <blockquote> <p>Each individual component of the gradient, <span class="math-container">$\partial C/\partial w_{jk}^{l}$</span> can be computed by the chain rule; but doing ...
281
backpropagation
Can positional encodings in transformers be added
https://ai.stackexchange.com/questions/43565/can-positional-encodings-in-transformers-be-added
<p>Here's a basic GPT2 implementation:</p> <pre><code>class GPT(nn.Module): def __init__(self, vocab_size, seq_len, model_dim, n_heads, n_layers): super().__init__() self.seq_len = seq_len self.wte = nn.Embedding(vocab_size, model_dim) self.wpe = nn.Embedding(seq_len, model_dim) ...
<p>Depends... for ViT yes, they are called learned positional encodings, and the reason is that you always have a fixed number of patches (at least theoretically)</p> <p>However, for NLP, you cannot do that, because at inference, you might have strings longer or shorter than the reference, and if you have trained only ...
282
backpropagation
What do you mean by &quot;updating based on a training example/batch&quot; in Gradient Descent?
https://ai.stackexchange.com/questions/43688/what-do-you-mean-by-updating-based-on-a-training-example-batch-in-gradient-des
<p>My understanding is this: When doing Stochastic Gradient Descent over a neural network, in every epoch, we run <span class="math-container">$n$</span> iterations (where the dataset has <span class="math-container">$n$</span> training examples) and in every iteration, we take a random sample and update the parameters...
<p>In batch gradient descent computing the loss function every time serves several purposes. While the value of the loss itself may not directly affect the backpropagation process, as you said monitoring the loss over time is essential to ensure that the optimization process is converging. Also many optimization algori...
283
backpropagation
Why are the weights of the previous layers updated only considering the old values of the weights of the later layer, not the updated values?
https://ai.stackexchange.com/questions/26136/why-are-the-weights-of-the-previous-layers-updated-only-considering-the-old-valu
<p>Why are the weights of a neural net updated only considering the old values of the later layer, not the already updated values?</p> <p>I use <a href="https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/" rel="nofollow noreferrer">this example</a> to explain my problem. When applying the backpropa...
<p>The basic idea of gradient descent is:</p> <ul> <li><p>Calculate the gradient of some score with respect to parameters that you can control</p> </li> <li><p>Take a step in the direction of that gradient that improves the score (subract a multiple of gradient - for gradient descent - if you want to minimise some cost...
284
backpropagation
Finding an optimum back propagation algorithm
https://ai.stackexchange.com/questions/4211/finding-an-optimum-back-propagation-algorithm
<p>I recently started working on very simple machine learning codes in Python and I came across a big problem: teaching the system to improve on its guesses.</p> <p>So this is what the code is about: I will have a list of organisms with their features stated in numerical values. I want to write a code that identifies...
<p>When you are training a neural network, you use an algorithm called back propagation. This algorithm uses partial derivatives to determine the optimal values for weights. Partial derivatives are a calculus based method which tell you how far you need to adjust the weights in order to get to an optimum value. However...
285
backpropagation
How does backprop work through the random sampling layer in a variational autoencoder?
https://ai.stackexchange.com/questions/33824/how-does-backprop-work-through-the-random-sampling-layer-in-a-variational-autoen
<p>Implementations of variational autoencoders that I've looked at all include a sampling layer as the last layer of the encoder block. The encoder learns to generate a mean and standard deviation for each input, and samples from it to get the input's representation in latent space. The decoder then attempts to decod...
<p>You do not backpropagate with respect to <span class="math-container">$\epsilon$</span>, which is the random sample or random variable (depending on how you look at it). You backpropagate with respect to the mean <span class="math-container">$\mu$</span> and variance <span class="math-container">$\sigma$</span> of t...
286
backpropagation
Do you need to store prevous values of weights and layers on recurrent layer while BPTT?
https://ai.stackexchange.com/questions/12657/do-you-need-to-store-prevous-values-of-weights-and-layers-on-recurrent-layer-whi
<p>The Back propagation through time on recurrent layer is defined similar to normal one, means somethin like </p> <p><code>self.deltas[x] = self.deltas[x+1].dot(self.weights[x].T) * self.layers[x] * (1- self.layers[x])</code> where </p> <p><code>self.deltas[x+1]</code> is error from prevous layer, <code>self.weigh...
<p>One word answer for your question "<strong>Do you need to store previous values of weights and layers on recurrent layer while BPTT?</strong>" is <strong>YES</strong></p> <p>Let us go through the details.</p> <p>For training an RNN using BPTT, we need gradients of error w.r.t all three parameters <strong>U</strong...
287
backpropagation
How does adding a small change to an neuron&#39;s weighted input affect the overall cost?
https://ai.stackexchange.com/questions/12682/how-does-adding-a-small-change-to-an-neurons-weighted-input-affect-the-overall
<p>I was reading the following book: <a href="http://neuralnetworksanddeeplearning.com/chap2.html" rel="nofollow noreferrer">http://neuralnetworksanddeeplearning.com/chap2.html</a></p> <p>and towards the end of equation 29, there is a paragraph that explains this: </p> <p><a href="https://i.sstatic.net/KkBdn.png" rel...
<p>I believe he's just saying that:</p> <p><span class="math-container">$$ \frac{\partial C}{\partial z_j^l} \Delta z_j^l \approx \frac{\partial C}{\partial z_j^l} \partial z_j^l \approx \partial C $$</span></p> <p>so that the change in cost function can be arrived at simply for a small enough perturbation <span clas...
288
backpropagation
Function to update weights in back-propagation
https://ai.stackexchange.com/questions/18213/function-to-update-weights-in-back-propagation
<p>I am trying to wrap my head around how weights get updated during back propagation. I've been going through a school book and I have the following setup for an ANN with 1 hidden layer, a couple of inputs and a single output. </p> <p><a href="https://i.sstatic.net/fVkiR.png" rel="nofollow noreferrer"><img src="https...
289
backpropagation
Different methods of calculating gradients of cost function(loss function)
https://ai.stackexchange.com/questions/19895/different-methods-of-calculating-gradients-of-cost-functionloss-function
<p>We require to find the gradient of loss function(cost function) w.r.t to the weights to use optimization methods such as SGD or gradient descent. So far, I have come across two ways to compute the gradient:</p> <ol> <li>BackPropagation</li> <li>Calculating gradient of loss function by calculus</li> </ol> <p>I foun...
<p>I'm pretty sure they're the same thing. Both backpropagation and gradient descent's essential ideas are to calculate the partial derivative of the cost with respect to each weight, and subtract the partial derivative times the learning rate.</p>
290
backpropagation
Training the generator in a GAN pair with back propagation
https://ai.stackexchange.com/questions/10053/training-the-generator-in-a-gan-pair-with-back-propagation
<p>For the purposes of this question I am asking about training the generator, assume that training the discriminator is another topic.</p> <p>My understanding of generative adversarial networks is that you feed random input data to the generator and it generates images. Out of those images, the ones which the discrim...
<p>I had this same problem some time ago, here's what you should do:</p> <p>notice how we first input i1 to the generator, that outputs o1, than we input o1 into the discriminator, that outputs y1, so the output from the first (o1) is the input to the second, but that's like if we combine the two networks into one from...
291
backpropagation
Computation of initial adjoint for NODE
https://ai.stackexchange.com/questions/24040/computation-of-initial-adjoint-for-node
<p>I'm reading the paper <a href="https://arxiv.org/pdf/1806.07366.pdf" rel="nofollow noreferrer">Neural Ordinary Differential Equations</a> and I have a simple question about adjoint method. When we train NODE, it uses a blackbox ODESolver to compute gradients through model parameters, hidden states, and time. It uses...
<p>First, a forward pass is done to obtain predictions of <span class="math-container">$z$</span>, at every <span class="math-container">$t$</span>. Then the adjoint state is run backward in time for every <span class="math-container">$t$</span>. Which gives the learning impulse. So an initial run is done to obtain val...
292
backpropagation
Creating a replacement for backpropagation through evolution
https://ai.stackexchange.com/questions/45746/creating-a-replacement-for-backpropagation-through-evolution
<p>Can we create a learning algorithm that solves all the problems of backpropagation through evolution?</p>
<p>What you are referring to are called evolutionary methods/genetic algorithms/zero order optimizers/many other names.</p> <p>However, it all depends on what you do with them. The core idea of evolution, and thus of this class of algorithms, is to &quot;apply some small perturbation, and only the strongest survive&quo...
293
backpropagation
Backpropagation with rasterization step
https://ai.stackexchange.com/questions/46614/backpropagation-with-rasterization-step
<p>I have an odd little problem facing me for my project.</p> <p>I have a smooth polygon defined by parameters.</p> <p>I have convolution transformation, similar to a Gaussian blur. This transformation can only be applied to an image.</p> <p>Consequently, I need to convert the polygon to an image. I then apply the tra...
294
backpropagation
Do we need backpropagation if there is only one class?
https://ai.stackexchange.com/questions/34937/do-we-need-backpropagation-if-there-is-only-one-class
<p>A am interested in physiologic neural network. Altough there are some opposite views, most probably there seems to be no plausible way to explain a physiologic backpropagation in the brain.</p> <p>So I am trying to code a neural network without backpropagation yet my mathematical understanding is inadaquate, so I w...
295
backpropagation
Why does &quot;in-place&quot; mutation cause automatic differentiation to fail, and how to write code to avoid this problem
https://ai.stackexchange.com/questions/43760/why-does-in-place-mutation-cause-automatic-differentiation-to-fail-and-how-to
<p>I work with a few different automatic differentiation frameworks, including pytorch, Jax, and Flux in Julia. Periodically I run some code and I get errors about mutations or operations occurring &quot;in-place.&quot; These errors generally cause the program to fail. <em>My question is, what does this error mean--in ...
<p>Here is my sense of the answer. In reverse model automatic differentiation (or backpropagation), the automatic differentiation library has to keep track of the values at each stage in the forward pass. These values are stored in memory.</p> <p>When values are changed in-place. then the values stored by the forward p...
296
backpropagation
Do neural networks do wishful thinking?
https://ai.stackexchange.com/questions/48451/do-neural-networks-do-wishful-thinking
<p>I will give an example of wishful thinking. When you try to prove a theorem you think what would imply that theorem and maybe try to find a lemma that implies it. Maybe neurons try to connect previous neurons that has the relevant information. I am not knowledgeable in the subject.</p>
<p>The short answer is no. The network isn't thinking, wishing, or desiring. The training process is simply trying to minimize the loss/error between the model output and the predicted output. The effect is that a complex function is modeled. It would be more correct to think of this in terms of an expectation functio...
297
backpropagation
Why do we update parameters with respect to cost instead of loss?
https://ai.stackexchange.com/questions/45044/why-do-we-update-parameters-with-respect-to-cost-instead-of-loss
<p>Assuming that the cost function <span class="math-container">$J$</span> is the average of the loss function <span class="math-container">$\mathcal{L}$</span> over all training examples <span class="math-container">$m$</span></p> <p><span class="math-container">$J(w) = \frac{1}{m} \displaystyle\sum_{i=0}^{m} \mathcal...
<p>The objective in parametric ML is to find parameter values that minimize the overall cost function <span class="math-container">$J(w)$</span> across the entire training dataset, whether in terms of the framework of empirical risk minimization (ERM) or information-theoretic cross-entropy (CE). Intuitively minimizing ...
298
backpropagation
Backpropogation rule for the output layer of a multi-layer network - What does the rule do in ambiguous cases?
https://ai.stackexchange.com/questions/25500/backpropogation-rule-for-the-output-layer-of-a-multi-layer-network-what-does-t
<p>This is the back-propogation rule for the output layer of a multi-layer network:</p> <p><span class="math-container">$$W_{jk} := W_{jk} - C \dfrac{\delta E}{\delta W_{jk}}$$</span></p> <p>What does this rule do in the more ambiguous cases such as:</p> <p>(1) The output of a hidden node is near the middle of a sigmoi...
<p>I assume you are considering a network where the activation function of the last layer is a sigmoid, so the output of your network is <span class="math-container">$$\tilde{y}=\sigma(W^{L}\cdot f(X, W^1, \dots, W^{L-1})),$$</span> where <span class="math-container">$X$</span> is the input vector, and <span class="mat...
299
gradient descent
How would 1D gradient descent look like?
https://ai.stackexchange.com/questions/3668/how-would-1d-gradient-descent-look-like
<p>We have always known that gradient descent is a function of two or more variables. But how can we geometrically represent gradient descent if it is a function of only one variable?</p>
<p>For a function of one variable, there are only two options for directions in the domain: left or right, so it becomes almost trivial, but you can still talk about gradient descent.</p> <p>You would take steps to the left if the slope/derivative is positive and make steps to the right if the slope/derivative is nega...
300
gradient descent
Numerical problems with gradient descent
https://ai.stackexchange.com/questions/36567/numerical-problems-with-gradient-descent
<p>I'm trying to implement a simple neural network for classification (multi-class) as an exercise (written in C). During gradient descent, the weights and biases quickly get out of control and the gradient becomes infinite.</p> <p>I haven't been able to find any discussion of such problems (vanishing gradients is kind...
<p>You're describing exploding gradients, which as you noted is the opposite issue of vanishing gradients. Both these problems arise from the process of propagating and backpropagating activations/errors through the network. The intuition is that repeated multiplications of numbers less than 1 rapidly leads to a produc...
301
gradient descent
Why use learning rate schedules if weight updates automatically decrease when approaching local optimal?
https://ai.stackexchange.com/questions/43523/why-use-learning-rate-schedules-if-weight-updates-automatically-decrease-when-ap
<p>Andrew Ng said in his slide that: <a href="https://i.sstatic.net/ImraM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ImraM.png" alt="enter image description here" /></a> However, there are numerous types of 'learning rate schedules' in TensorFlow that change the learning rate profile as training pro...
<p>In one hand you have the fact that if the initial step-size is a bit too optimistic, decay will at some point lead to a step-size that works</p> <p>However, there is a much more theoretical reason for it.<br /> Indeed if you consider a non-smooth function, it's necessary sometimes to converge to decay your stepsize....
302
gradient descent
Softmax gradient for automatic differentiation
https://ai.stackexchange.com/questions/47062/softmax-gradient-for-automatic-differentiation
<p>imaging input vector a = {a1,a2,a3} and z = softmax(a) = {z1,z2,z3}</p> <p>So, we expect than gradient of z with respect of a would be the same shape as vector a (so we can make gradient step: a = a - learning rate * dz/da). But the real shape is (3,3). So what should i do to make the gradient step? <a href="https:/...
<p>(ignoring the fact that is probably the other way around, meaning <span class="math-container">$z$</span> are the logits, <span class="math-container">$a = softmax(z)$</span>)</p> <p>Automatic differentiation expects you to take the derivative of a function <span class="math-container">$f: R^N \rightarrow R$</span>,...
303
gradient descent
How can I train a neural network to find the hyper-parameters with which the data was generated?
https://ai.stackexchange.com/questions/17239/how-can-i-train-a-neural-network-to-find-the-hyper-parameters-with-which-the-dat
<p>I have 10000 tuples of numbers <code>(x1, x2, y)</code> generated from the equation: <code>y = np.cos(0.583 * x1) + np.exp(0.112 * x2)</code>. I want to use a neural network, trained with gradient descent, in PyTorch, to find the 2 parameters, i.e. 0.583 and 0.112</p> <p>Here is my code:</p> <pre><code>class NN_te...
304
gradient descent
How is the loss value calculated in order to compute the gradient?
https://ai.stackexchange.com/questions/17295/how-is-the-loss-value-calculated-in-order-to-compute-the-gradient
<p>The gradient descent step is the following</p> <p><span class="math-container">\begin{align} \mathbf{W}_i = \mathbf{W}_{i-1} - \alpha * \nabla L(\mathbf{W}_{i-1}) \end{align}</span></p> <p>were <span class="math-container">$L(\mathbf{W}_{i-1})$</span> is the loss value, <span class="math-container">$\alpha$</span>...
<p>In your case, <span class="math-container">$L$</span> is the loss (or cost) function, which can be, for example, the <a href="https://en.wikipedia.org/wiki/Mean_squared_error" rel="nofollow noreferrer">mean squared error (MSE)</a> or the cross-entropy, depending on the problem you want to solve. Given one training e...
305
gradient descent
Is there anything that ensures that convolutional filters end up different from one another?
https://ai.stackexchange.com/questions/25464/is-there-anything-that-ensures-that-convolutional-filters-end-up-different-from
<p>I found this <a href="https://ai.stackexchange.com/questions/25109/is-there-anything-that-ensures-that-convolutional-filters-dont-end-up-the-same">question</a> very interesting, and this is a follow up on it.</p> <p>Presumably, we'd want all the filters to converge towards some complementary set, where each filter f...
<p>Yes, your thought experiment is correct, and the concept is known as <strong>breaking the symmetry</strong>. This is why biases can be initialized to <span class="math-container">$0$</span> (bias initialization doesn't matter), but weights should be randomly initialized to different numbers -- to break the symmetry....
306
gradient descent
Optimizer that prevents parameters from oscillating
https://ai.stackexchange.com/questions/27117/optimizer-that-prevents-parameters-from-oscillating
<p>When we perform gradient descent, especially in an online setting where the training data is presented in a non-random order, a particular 1-dimensional parameter (such as an edge weight) may first travel in one direction, then turn around and travel the other way for a while, then turn around and travel back, and s...
307
gradient descent
Behaviour of cost
https://ai.stackexchange.com/questions/7362/behaviour-of-cost
<p>In doing a project using neural networks with an input layer, 4 hidden layers and an output layer ,I used mini batch gradient descent. I noticed that the randomly initialised weights seemed to do a good performance and gave a low error. As the model started training after about 200 iterations there was large jump in...
<p>I would say just don't go for using regularization at first, try with lower <code>learning rate = 0.0001</code> see the behavior. Try to post entire architecture of your model so that one can better answer your problem.</p>
308
gradient descent
Should I use batch gradient descent when I have a small sample size?
https://ai.stackexchange.com/questions/26468/should-i-use-batch-gradient-descent-when-i-have-a-small-sample-size
<p>I have a dataset with an input size of 155x155, with the output being 155 x 1 with a 3-4 layer neural net being used for regression. With such a small sample size, should I use full batch gradient descent (so all 155 samples) or use mini batch/stochastic gradient descent. I have read that using smaller mini batch si...
309
gradient descent
Do good approximations produce good gradients?
https://ai.stackexchange.com/questions/8080/do-good-approximations-produce-good-gradients
<p>Let’s say I have a neural net doing classification and I’m doing stochastic gradient descent to train it. If I know that my current approximation is a decent approximation, can I conclude that my gradient is a decent approximation of the gradient of the true classifier everywhere?</p> <p>Specifically, suppose that ...
<p>In general <span class="math-container">$|f(x) - f_k(x)| \leq \epsilon$</span> doesn't ensure <span class="math-container">$|\nabla f(x) - \nabla f_k(x)| \leq c\epsilon$</span>. And for neural networks there is no reason to believe it will happen either. </p> <p>You can also look at Sobolev Training Paper (<a href=...
310
gradient descent
Does gradient descent in deep learning assume a smooth fitness landscape?
https://ai.stackexchange.com/questions/27231/does-gradient-descent-in-deep-learning-assume-a-smooth-fitness-landscape
<p>I've come across the concept of fitness landscape before and, in my understanding, a smooth fitness landscape is one where the algorithm can converge on the global optimum through incremental movements or iterations across the landscape.</p> <p>My question is: <strong>Does deep learning assume that the fitness lands...
<p>I'm going to take the fitness landscape to be the <a href="https://en.wikipedia.org/wiki/Graph_of_a_function#Definition" rel="nofollow noreferrer">graph</a> of the loss function, <span class="math-container">$\mathcal{G} = \{\left(\theta, L(\theta)\right) : \theta \in \mathbb{R}^n\}$</span>, where <span class="math-...
311