-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from bartvm/dataset_tests
Fixes MNIST and runs test on Travis
- Loading branch information
Showing
4 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from numpy.testing import assert_raises | ||
|
||
from blocks.datasets.mnist import MNIST | ||
|
||
|
||
def test_mnist(): | ||
mnist_train = MNIST('train', start=20000) | ||
assert len(mnist_train.X) == 40000 | ||
assert len(mnist_train.y) == 40000 | ||
mnist_test = MNIST('test', sources=('targets',)) | ||
assert len(mnist_test.X) == 10000 | ||
assert len(mnist_test.y) == 10000 | ||
|
||
first_feature, first_target = mnist_train.get_data(request=[0]) | ||
assert first_feature.shape == (1, 784) | ||
assert first_target.shape == (1, 1) | ||
|
||
first_target, = mnist_test.get_data(request=[0, 1]) | ||
assert first_target.shape == (2, 1) | ||
|
||
binary_mnist = MNIST('test', binary=True, sources=('features',)) | ||
first_feature, = binary_mnist.get_data(request=[0]) | ||
assert first_feature.dtype.kind == 'b' | ||
assert_raises(ValueError, MNIST, 'valid') |