Hello,
I am trying to use Binary Cross Entropy Loss (BCE loss) for Simese network.
I have two inputs for BCE loss function:
- output
(input_dy)
→ tensor of size [4] , output of neural network - true_labels
(y_true)
→ tensor of size [4], target (true value)
For BCE loss, the input parameters must be of the dimension:
- output
(input_dy)
→ [Batch_size, no. of classes] - true_labels
(y_true)
→ [Batch_size]
The following diagram explains the query:
I need a function in python using pytorch to convert the dy
matrix to a 2D matrix with the output probabilities that sum to 1. [To note: dy
should be iterated through length of it, as it is the output of the network for every input ]
Further a 2D array must be represented into one hot encoding, which will be true_labels (that will represent Binary classes with 0 & 1)
I need both output matrix and true_labels matrix for BCE Loss with following dimensions:
- output dimension → [4, 2]
- true_labels → [4]
Any help is most appreciated!
Thank you in advance. @ptrblck