MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / ToyLossLayer

Class ToyLossLayer

lstm_code/nicodjimenez/test2.py:6–18  ·  view source on GitHub ↗

Computes square loss with first element of hidden layer array.

Source from the content-addressed store, hash-verified

4from lstm import LstmParam, LstmNetwork
5
6class ToyLossLayer:
7 """
8 Computes square loss with first element of hidden layer array.
9 """
10 @classmethod
11 def loss(self, pred, label):
12 return (pred[0] - label) ** 2
13
14 @classmethod
15 def bottom_diff(self, pred, label):
16 diff = np.zeros_like(pred)
17 diff[0] = 2 * (pred[0] - label)
18 return diff
19
20class Primes:
21 def __init__(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected