MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / smoothed_loss

Function smoothed_loss

nlp_class2/logistic.py:113–120  ·  view source on GitHub ↗
(x, decay=0.99)

Source from the content-addressed store, hash-verified

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

Callers 1

logistic.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected