def backward(self, outputs, targets):
"""SoftmaxCategoricalCrossEntropy backward propagation.
.. math:: dE = p - t
Parameters
----------
outputs : numpy 2D array
Predictions in (0, 1), such as softmax output of a neural network,
with data points in rows and class probabilities in columns.
targets : numpy 2D array
Either targets in [0, 1] matching the layout of `outputs`, or
a vector of int giving the correct class index per data point.
Returns
-------
numpy 1D array
"""
outputs = np.clip(outputs, self.epsilon, 1 - self.epsilon)
return outputs - targets
评论列表
文章目录