MCPcopy Create free account
hub / github.com/MingchaoZhu/DeepLearning / loss

Method loss

code/chapter6.py:212–219  ·  view source on GitHub ↗

参数说明: y_true:训练的 n 个样本的真实值, 形状为(n,m)数组; y_pred:训练的 n 个样本的预测值, 形状为(n,m)数组;

(y_true, y_pred)

Source from the content-addressed store, hash-verified

210
211 @staticmethod
212 def loss(y_true, y_pred):
213 """
214 参数说明:
215 y_true:训练的 n 个样本的真实值, 形状为(n,m)数组;
216 y_pred:训练的 n 个样本的预测值, 形状为(n,m)数组;
217 """
218 (n, _) = y_true.shape
219 return 0.5 * np.linalg.norm(y_pred - y_true) ** 2 / n
220
221 @staticmethod
222 def grad(y_true, y_pred, z, acti_fn):

Callers 2

__call__Method · 0.95
fitMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected