MCPcopy
hub / github.com/MingchaoZhu/DeepLearning / evaluate

Method evaluate

code/chapter9.py:1205–1215  ·  view source on GitHub ↗
(self, X_test, y_test, batch_size=128)

Source from the content-addressed store, hash-verified

1203 prev_loss = loss
1204
1205 def evaluate(self, X_test, y_test, batch_size=128):
1206 acc = 0.0
1207 batch_generator, n_batch = minibatch(X_test, batch_size, shuffle=True)
1208 for j, batch_idx in enumerate(batch_generator):
1209 batch_len, batch_start = len(batch_idx), time.time()
1210 X_batch, y_batch = X_test[batch_idx], y_test[batch_idx]
1211 y_pred_batch, _ = self.forward(X_batch)
1212 y_pred_batch = np.argmax(y_pred_batch, axis=1)
1213 y_batch = np.argmax(y_batch, axis=1)
1214 acc += np.sum(y_pred_batch == y_batch)
1215 return acc / X_test.shape[0]
1216
1217 @property
1218 def hyperparams(self):

Callers

nothing calls this directly

Calls 2

forwardMethod · 0.95
minibatchFunction · 0.90

Tested by

no test coverage detected