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

Method evaluate

code/chapter6.py:389–399  ·  view source on GitHub ↗
(self, X_test, y_test, batch_size=128)

Source from the content-addressed store, hash-verified

387 prev_loss = loss
388
389 def evaluate(self, X_test, y_test, batch_size=128):
390 acc = 0.0
391 batch_generator, n_batch = minibatch(X_test, batch_size, shuffle=True)
392 for j, batch_idx in enumerate(batch_generator):
393 batch_len, batch_start = len(batch_idx), time.time()
394 X_batch, y_batch = X_test[batch_idx], y_test[batch_idx]
395 y_pred_batch, _ = self.forward(X_batch)
396 y_pred_batch = np.argmax(y_pred_batch, axis=1)
397 y_batch = np.argmax(y_batch, axis=1)
398 acc += np.sum(y_pred_batch == y_batch)
399 return acc / X_test.shape[0]
400
401 @property
402 def hyperparams(self):

Callers

nothing calls this directly

Calls 2

forwardMethod · 0.95
minibatchFunction · 0.85

Tested by

no test coverage detected