I have output with dimension batch_size x 14 x 100 (14 object x 100 classes). I want to do cross-entropy loss with ground truth indices provided with dimension batch_size x 14. However, when I use torch.functional.cross_entropy, I get the error message that says Expected target size [15, 100], got [15, 14]. Does anyone know what the reason is?
Thank you in advance
How to do PyTorch F.cross_entropy?
268 Views Asked by ryan chandra At
1
There are 1 best solutions below
Related Questions in PYTORCH
- Pytorch install with anaconda error
- How should I save the model of PyTorch if I want it loadable by OpenCV dnn module
- PyTorch: memorize output from several layers of sequencial
- in Pytorch, restore the model parameters but the same initial loss
- Seq2seq pytorch Inference slow
- Why does autograd not produce gradient for intermediate variables?
- pytorch inception model outputs the wrong label for every input image
- "expected CPU tensor(got CUDA tensor)" error for PyTorch
- Float16 (HalfTensor) in pytorch + cuda
- Access parameter names in torch
- Efficient way of calculating sum of unequal sized chunks of tensor in Pytorch
- what is the equivalent of theano.tensor.clip in pytorch?
- How can I do scatter and gather operations in NumPy?
- How do I write a PyTorch sequential model?
- How to combine multiple models together?
Related Questions in CROSS-ENTROPY
- Tensorflow R0.12 softmax_cross_entropy_with_logits ASSERT Error
- Tensorflow - loss starts high and does not decrease
- What is the meaning of the word logits in TensorFlow?
- PyTorch equivalence for softmax_cross_entropy_with_logits
- What is the difference between a sigmoid followed by the cross entropy and sigmoid_cross_entropy_with_logits in TensorFlow?
- How can I create a custom loss function in keras ? (Custom Weighted Binary Cross Entropy)
- How is cross entropy loss work in pytorch?
- tf keras SparseCategoricalCrossentropy and sparse_categorical_accuracy reporting wrong values during training
- How to create weighted cross entropy loss?
- Can you use perplexity to guess the language of a document?
- How to do PyTorch F.cross_entropy?
- Pytorch CrossEntropy Loss, getting error: "RuntimeError: Boolean value of Tensor with more than one value is ambiguous"
- Tensorflow binary classifier with weighted loss function - Why does train history accuracy doesn't match train accuracy?
- Problem replicating a comparison between CE and MSE
- Suppose logits are a 3*4 matrix, and the target is a 1*3, how is cross-entropy loss calculated mathematically?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
See the cross entropy documentation
For higher dim inputs, the inputs and targets are expected to be of size
(N, C, d_1, ... d_k)and(N, d_1, ... d_k)whereNis the batch size andCis the number of classes.Your output should be of shape
batch_size x 100 x 14rather thanbatch_size x 14 x 100