MCPcopy Index your code
hub / github.com/MingchaoZhu/DeepLearning / evaluate

Method evaluate

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

Source from the content-addressed store, hash-verified

989 prev_loss = loss
990
991 def evaluate(self, X_test, y_test, batch_size=128):
992 acc = 0.0
993 batch_generator, n_batch = minibatch(X_test, batch_size, shuffle=True)
994 for j, batch_idx in enumerate(batch_generator):
995 batch_len, batch_start = len(batch_idx), time.time()
996 X_batch, y_batch = X_test[batch_idx], y_test[batch_idx]
997 y_pred_batch, _ = self.forward(X_batch)
998 y_pred_batch = np.argmax(y_pred_batch, axis=1)
999 y_batch = np.argmax(y_batch, axis=1)
1000 acc += np.sum(y_pred_batch == y_batch)
1001 return acc / X_test.shape[0]
1002
1003 @property
1004 def hyperparams(self):

Callers

nothing calls this directly

Calls 2

forwardMethod · 0.95
minibatchFunction · 0.90

Tested by

no test coverage detected