MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / train_epoch

Method train_epoch

mla/neuralnet/optimizers.py:39–58  ·  view source on GitHub ↗
(self, network)

Source from the content-addressed store, hash-verified

37 raise NotImplementedError
38
39 def train_epoch(self, network):
40 losses = []
41
42 # Create batch iterator
43 X_batch = batch_iterator(network.X, network.batch_size)
44 y_batch = batch_iterator(network.y, network.batch_size)
45
46 batch = zip(X_batch, y_batch)
47 if network.verbose:
48 batch = tqdm(
49 batch, total=int(np.ceil(network.n_samples / network.batch_size))
50 )
51
52 for X, y in batch:
53 loss = np.mean(network.update(X, y))
54 self.update(network)
55 losses.append(loss)
56
57 epoch_loss = np.mean(losses)
58 return epoch_loss
59
60 def train_batch(self, network, X, y):
61 loss = np.mean(network.update(X, y))

Callers 1

optimizeMethod · 0.95

Calls 3

updateMethod · 0.95
batch_iteratorFunction · 0.90
updateMethod · 0.45

Tested by

no test coverage detected