At test time AlexNet does not look at one crop. It cuts ten patches from the image (four corners, the centre, and the mirror image of each), runs all ten through the network, and averages the softmax outputs. For its competition entry it also averaged the predictions of several CNNs. Implement both.
softmax(z)
ten_patches(image, size)
image has shape (H, W, C). Return an array of shape (10, size, size, C) holding, in this order: top-left, top-right, bottom-left, bottom-right and centre patches, then the same five mirrored left to right.(H - size) // 2 and column (W - size) // 2.predict_ten(image, net, size)
net maps a batch of shape (n, size, size, C) to logits of shape (n, K). Run it once on the ten patches, apply softmax to each row and return the mean probability vector (shape (K,)).ensemble_predict(image, nets, size)
predict_ten(image, net, size) over the list nets.ensemble_predict is an average of averages; with equal weights it is the average over every (network, patch) pair.