MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / smoothed_loss

Function smoothed_loss

nlp_class2/neural_network.py:117–124  ·  view source on GitHub ↗
(x, decay=0.99)

Source from the content-addressed store, hash-verified

115
116 # plot smoothed losses to reduce variability
117 def smoothed_loss(x, decay=0.99):
118 y = np.zeros(len(x))
119 last = 0
120 for t in range(len(x)):
121 z = decay * last + (1 - decay) * x[t]
122 y[t] = z / (1 - decay ** (t + 1))
123 last = z
124 return y
125
126 plt.plot(smoothed_loss(losses))
127 plt.show()

Callers 1

neural_network.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected