# Tag Info

Accepted

### How do I handle negative rewards in policy gradients with the cross-entropy loss function?

The cross-entropy loss will always be positive because the probability is in the range $[0, 1]$, so $-ln(p)$ will always be positive.

### How to formalize learning in terms of information theory?

In short: It is easy to quantify information, but it is not easy to quantify its usefulness I'm not sure how exactly you are looking to formalise your experiment, but it might be helpful to consider ...
Accepted

### Are sentences from the same document independent and identically distributed?

The sentences coming from the same document, author, etc., are unlikely to be independent, that is, the occurrence of a sentence $s_i$ in a certain document $d$ is likely correlated with the ...
Accepted

### Which loss function should I use in REINFORCE, and what are the labels?

The loss function you are looking for is cross entropy loss. The 'label' that you use is the action you took at the time point you are updating for.

### Why do non-linear activation functions that produce values larger than 1 or smaller than 0 work?

Why wouldn't they work? Each neuron's output is equal to a function over the sum of all its weights multiplied by their corresponding neurons. If that function is the Sigmoid function, then the output ...
Accepted

### Why is the cross-entropy a cost function?

Optimizing the cross-entropy is equivalent to optimizing the log-likelihood of the parameters given the data, $\ell(\theta)$, which is what we want, i.e. find the parameters that most likely generated ...

### What loss function will be correlated with classification metrics?

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). Further, metrics like ...

### why cross entropy loss has to be multiplied by a batch size during an evaluation in transformer model?

That is because the default reduction for the CEP loss calculation is mean. Hence to find the true average across all batches, you first multiply by the batch size and then divide by total number of ...
1 vote

### Backpropagation with CrossEntropy and Softmax, HOW?

The derivation of the softmax function is a bit tricky because except the other common activation functions(sigmoid, relu...) all the Zs values impact each other. It is because when you are ...
1 vote

### Backpropagation with CrossEntropy and Softmax, HOW?

No it's not the same. First the derivative of the cost function is taken with respect to the weight and not the input. This is usually done using the chain rule of calculus. To calculate this using ...
1 vote
Accepted

### What is the correct loss function for binary classification: Cross entropy or Binary cross entropy?

Binary cross-entropy loss is a specific case for cross-entropy loss. Theoretically, one can also use the normal cross-entropy loss for binary classification. Binary cross-entropy is probably ...
1 vote
Accepted

### Trouble writing the backpropagation algorithm in python through crossentropy and softmax

I found the bug on my code, now everything works just fine, so I am fairly sure that the derivation of the formulas is on point. Optimisation wise, clearly using the short formula on the end of the ...
1 vote

### In logistic regression, why is the binary cross-entropy loss function convex?

I'm unable to comment on previous answers because I'm new to ai.stackexchange and don't have enough clout points. So I'm writing my comment as an answer instead. Unless I'm missing something, I ...
1 vote

### In logistic regression, why is the binary cross-entropy loss function convex?

If you find the Hessian matrix (the matrix of second order derivatives) for the binary cross entropy loss function, you'll see that it is positive semidefinite for any possible value of the parameters....
1 vote
Accepted

### What error should I use for RNN?

To provide a good answer would fill several pages. To keep it very simple try many different loss functions on your model. Your goal is to have the highest performance based on some desired ...
1 vote

### How to compute the gradient of the cross-entropy loss function with respect to the parameters with softmax activation function?

Alright. Consider an ordinary neural network, so, in the last layer, we have, $z^{[L]} = W^{[L]} a^{[L-1]} + b^{[L]}$, where $a^{[L]} = \sigma(z^{[L]})$, where $\sigma$ is the softmax activation:  \...
1 vote
Accepted

### Have I understood the loss function from the original U-Net paper correctly?

Yes, $E$ is the cross-entropy function and a direct generalization of the binary case. For the binary case, probability to belong to the class $1$ is given by a sigmoid function $\sigma(x)$ of the ...
1 vote

### Where is the mistake in my derivation of the GAN loss function?

$\textbf{Remark.}$ I'd leave this as a comment if I could. Regarding notation (which I believe may be the cause of your issue here), the loss function is better written as \begin{align*} \operatorname{...
1 vote

### What is the advantage of using cross entropy loss & softmax?

Short answer: larger gradients That is not the derivative of the softmax function. $t - o$ is the combined derivative of the softmax function and cross entropy loss. Cross entropy loss is used to ...
1 vote

### How do you manage negative rewards in policy gradients?

You don't need to manage negative rewards separately, if you implemented the algorithm correctly it will work regardless if the rewards are negative or not. You seem to be using rewards for the loss ...
1 vote
Accepted

### How should I penalize the model proportionally to the error?

I want to make it so that if the correct label is 3, then it will penalize the model less heavily if it classifies a 4 than a 7 because 4 is closer numerically to 3 than 7 is. How do I do this? ...
1 vote
Accepted

### Why does PyTorch use a different formula for the cross-entropy?

When you one-hot-encode your labels with $p_i \in \{0,1\}$ you get $p_i = 0$ iff $i$ is not correct and, equivalently, $p_i =1$ iff $i$ is correct. Hence, $p_i \log(q_i) = 0 \log(q_i) = 0$ for all ...
1 vote

### Why does the binary cross-entropy work better than categorical cross-entropy in a multi-class single label problem?

https://stats.stackexchange.com/questions/260505/machine-learning-should-i-use-a-categorical-cross-entropy-or-binary-cross-entro Is relevant. based on my reading when you have a NN and do Binary ...

Only top scored, non community-wiki answers of a minimum length are eligible