-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhelpers.lua
60 lines (47 loc) · 1.48 KB
/
helpers.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- helpers
function waitForEnter()
local input
repeat
print("Press <Enter> to continue.")
input = io.read()
until string.lower(input) == ""
end
function getMnist()
----------------------------------------------------------------------
-- This script downloads and loads the MNIST dataset
-- http://yann.lecun.com/exdb/mnist/
----------------------------------------------------------------------
-- Here we download dataset files.
-- Note: files were converted from their original LUSH format
-- to Torch's internal format.
-- The SVHN dataset contains 3 files:
-- + train: training data
-- + test: test data
local tar = 'http://torch7.s3-website-us-east-1.amazonaws.com/data/mnist.t7.tgz'
local train_file = 'mnist.t7/train_32x32.t7'
local test_file = 'mnist.t7/test_32x32.t7'
local missing = false
if not paths.filep(train_file) or not paths.filep(test_file) then
missing = true
end
if missing and not paths.dirp('mnist.t7') then
print '==> downloading MNIST dataset'
os.execute('wget ' .. tar)
end
if missing then
os.execute('tar xvf ' .. paths.basename(tar))
end
----------------------------------------------------------------------
print '==> loading MNIST dataset'
-- We load the dataset from disk, it's straightforward
trainData = torch.load(train_file,'ascii')
testData = torch.load(test_file,'ascii')
print('Training Data:')
print(trainData)
print()
print('Test Data:')
print(testData)
print()
print '==> done'
return trainData,testData
end