while reading about neural network i came across
`class Loss_CategoricalCrossentropy(Loss):
# Backward pass
def backward(self, dvalues, y_true):
# Number of samples
samples = len(dvalues)
# Number of labels in every sample
# We'll use the first sample to count them
labels = len(dvalues[0])
# If labels are sparse, turn them into one-hot vector
if len(y_true.shape) == 1:
y_true = np.eye(labels)[y_true]
# Calculate gradient
self.dinputs = -y_true / dvalues'`
i dont understand how the formula for self.dinputs was obtained
i tried to use chain rule i got -y_true*dvalues
New contributor
qwerty is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.