Ejemplo n.º 1
0
def main():
    mnist = Mnist(os.path.join(os.getcwd(), "datasets/train.csv"), rows=100)
    for dataset in mnist.random()[:1]:
        # reshape from 1x784 to 28x28 and scale to 0-1
        array = numpy.asfarray(dataset.data).reshape((28, 28)) / 255
        fig, ax = plt.subplots()
        im = ax.imshow(array, cmap=plt.get_cmap('Greys'), interpolation='None')
        fig.colorbar(im)
        ax.set_title(dataset.label)
        plt.show()
Ejemplo n.º 2
0
class TestMnist(unittest.TestCase):
    """ Tests ... """
    def setUp(self):
        self._mnist = Mnist(
            os.path.join(os.path.dirname(__file__), 'resources/mnist.csv'))

    def tearDown(self):
        pass

    def test_load_data(self):
        """
        Test case for ...
        """
        assert len(self._mnist.get()) == 10
        assert self._mnist.get()[0].label == 7
        pass

    def test_rand(self):
        """
        Test case for ...
        """
        assert len(self._mnist.random()[:5]) == 5
        pass