MCPcopy Create free account
hub / github.com/numpy/numpy / train

Method train

benchmarks/benchmarks/bench_ufunc_strides.py:202–209  ·  view source on GitHub ↗
(self, max_epoch)

Source from the content-addressed store, hash-verified

200
201 timeout = 1000
202 def train(self, max_epoch):
203 for epoch in range(max_epoch):
204 z = np.matmul(self.X_train, self.W)
205 A = 1 / (1 + np.exp(-z)) # sigmoid(z)
206 loss = -np.mean(self.Y_train * np.log(A) + (1-self.Y_train) * np.log(1-A))
207 dz = A - self.Y_train
208 dw = (1/self.size) * np.matmul(self.X_train.T, dz)
209 self.W = self.W - self.alpha*dw
210
211 def setup(self, dtype):
212 np.random.seed(42)

Callers 1

time_trainMethod · 0.95

Calls 1

meanMethod · 0.45

Tested by

no test coverage detected