Skip to main content
2 votes
1 answer
37 views

How do I update pixelClassificationLayer() to a custom loss function?

I have seen in the Mathworks official website for the pixelClassificationLayer() function that I should update it to a custom loss function using the following code: function loss = modelLoss(Y,T) ...
JAIME GOMEZ's user avatar
0 votes
1 answer
201 views

Cross-entropy loss with varying number of classes

Is there a standard/efficient way in Pytorch to handle cross-entropy loss for a classification problem where the number of classes depends on the sample? Example: In a batch of size 3, I have: logits1 ...
SuperTardigrade's user avatar
0 votes
1 answer
105 views

Backward pass of Softmax with CrossEntropy

I'm trying to calculate the Softmax backward pass; fn softmax_backward(&self, logits: &Vec<f32>) -> Vec<f32> { let probability = self.forward(logits); let mut derivative ...
Hallvard's user avatar
-1 votes
1 answer
54 views

How to track loss of multi-label MLP?

I am given binary data points of dimension 5,000. I am asked to perform machine learning predicting a binary vector of length 1k, where each position of the output is a class. The classes are not ...
Tim's user avatar
  • 53
0 votes
1 answer
76 views

Analytical gradient of Softmax entropy loss does not match the numerical gradient

I'm trying to implement the gradient of the softmax entropy loss in Python. However, I can see that the analytical gradient does not match the numeric gradient. Here is my Python code: import numpy as ...
Jawad Damir's user avatar
0 votes
1 answer
173 views

Why does my CNN for a Binary Classification problem have a constant 50% accuracy with BCELoss vs 80%+ with Cross Entropy Loss?

I am creating a CNN from scratch with Pytorch. I have a balanced dataset of images, split in half for both classes. I am trying to use the BCEwithLogitsLoss function from torch.nn as I have read that ...
JNuevo's user avatar
  • 1
0 votes
1 answer
92 views

cross entropy loss and torch weights mismatch

My targets are primarily class 0, less frequently class 1 or 2 Trying to do cross entropy loss with class weights The following code weights = torch.tensor([1., 10, 10.]).to(device) lossfn = nn....
Lcat's user avatar
  • 929
0 votes
1 answer
98 views

Medical Binary Classification probability : BCE vs CrossEntropy

I am a medical resident that really enjoys learning about ML, I spent a lot of time reading here and want to make use of it in my field, medical imaging. We have an exam called "Datscan ...
Quazality's user avatar
1 vote
1 answer
440 views

Accessing the N values of PyTorch's Cross-Entropy loss function

I am trying to access specific values of PyTorch's Cross-Entropy loss function (torch.nn.functional.cross_entropy) that I believe are being calculated when the input is a vector of length N. I would ...
K Medlin's user avatar
0 votes
1 answer
60 views

CrossEntropyLoss loss function type problem

I am trying to solve a classification problem but something is not working for me in the code. I have a network that receives 30 inputs and outputs 4 actions. Each action can receive an integer value ...
May's user avatar
  • 1
0 votes
0 answers
24 views

Why categorical_crossentropy gives 16?

I'm trying to calculate the math behind the code: import tensorflow as tf import numpy as np y_pred_one_hot = np.array([0, 0, 0, 1], dtype='float32') y_true_one_hot = np.array([0, 1, 0, 0], dtype='...
user3668129's user avatar
  • 4,860
0 votes
1 answer
112 views

Pytorch's `binary_cross_entropy` seems to implement ln(0) = -100. Why?

I'm curious as to why Pytorch's binary_cross_entropy function seems to be implemented in such a way to calculate ln(0) = -100. The binary cross entropy function from a math point of view calculates: H ...
Gustavo Mirapalheta's user avatar
0 votes
1 answer
59 views

What causes this model to not improve?

I'm very new to pytorch and have a system that I believe can unpack and run through data, but when it does so the accuracy it returns with, even after hundreds of epochs, is still worse than random ...
spookysynth's user avatar
3 votes
1 answer
269 views

Pytorch CrossEntropy Loss, getting error: "RuntimeError: Boolean value of Tensor with more than one value is ambiguous"

I have a classification model, producing predictions for 4 classes in a tensor of shape (256, 1, 4)...256 is the batch size, while the "1" for the second dimension is due to some model ...
Carlo's user avatar
  • 1,590
0 votes
1 answer
35 views

Tensorflow binary classifier with weighted loss function - Why does train history accuracy doesn't match train accuracy?

I'm trainig a NN with the following code: model = tf.keras.Sequential([ tf.keras.layers.InputLayer(input_shape=(input_length,)), tf.keras.layers.Dropout(0.8, seed=42), tf.keras.layers....
mat.tho's user avatar
  • 204

15 30 50 per page
1
2 3 4 5
24