Last active
August 29, 2015 14:21
-
-
Save guy4261/3e959fec2c838bcc239a to your computer and use it in GitHub Desktop.
Normalize the mnist train data in the Torch tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('torch') | |
-- Find the average per image | |
train = torch.load('mnist.t7/train_32x32.t7', 'ascii') | |
train.data = train.data:type(torch.getdefaulttensortype()) | |
BOUND = 60000 -- Perform on the full data | |
-- BOUND = 1 -- You can test on a single image as a beginning | |
for index = 1, BOUND do | |
cells = train.data[index][1] | |
avg = 0 | |
mean = cells:mean() | |
std = cells:std() | |
cells = (cells - mean) / std | |
train.data[index][1] = cells | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment