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

Function smoothed_loss

nlp_class2/neural_network2.py:140–147  ·  view source on GitHub ↗
(x, decay=0.99)

Source from the content-addressed store, hash-verified

138
139 # plot smoothed losses to reduce variability
140 def smoothed_loss(x, decay=0.99):
141 y = np.zeros(len(x))
142 last = 0
143 for t in range(len(x)):
144 z = decay * last + (1 - decay) * x[t]
145 y[t] = z / (1 - decay ** (t + 1))
146 last = z
147 return y
148
149 plt.plot(smoothed_loss(losses))
150 plt.show()

Callers 1

neural_network2.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected