From 7bfde8e5cc7dd9efb1d2fe466b3e7eafd027d88a Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 15 Mar 2018 02:10:28 +0100 Subject: [PATCH] rewrite main to dump tables instead --- README.md | 67 +++++++++------------------------------------- mnists/__main__.py | 22 ++++++++++----- 2 files changed, 28 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 725515f..bbe66a4 100644 --- a/README.md +++ b/README.md @@ -34,62 +34,19 @@ pass `flatten=True` to `mnists.prepare` to get (n, 784). ## datasets -in alphabetical order: - -### [emnist][emnist] - - * `emnist_balanced` - train images shape: (112800, 1, 28, 28) - train labels shape: (112800, 47) - test images shape: (18800, 1, 28, 28) - test labels shape: (18800, 47) - - * `emnist_byclass` - train images shape: (697932, 1, 28, 28) - train labels shape: (697932, 62) - test images shape: (116323, 1, 28, 28) - test labels shape: (116323, 62) - - * `emnist_bymerge` - train images shape: (697932, 1, 28, 28) - train labels shape: (697932, 47) - test images shape: (116323, 1, 28, 28) - test labels shape: (116323, 47) - - * `emnist_digits` - train images shape: (240000, 1, 28, 28) - train labels shape: (240000, 10) - test images shape: (40000, 1, 28, 28) - test labels shape: (40000, 10) - - * `emnist_letters` - train images shape: (124800, 1, 28, 28) - train labels shape: (124800, 26) - test images shape: (20800, 1, 28, 28) - test labels shape: (20800, 26) - - * `emnist_mnist` - train images shape: (60000, 1, 28, 28) - train labels shape: (60000, 10) - test images shape: (10000, 1, 28, 28) - test labels shape: (10000, 10) - -### [fashion-mnist][fashion-mnist] - - * `fashion_mnist` - train images shape: (60000, 1, 28, 28) - train labels shape: (60000, 10) - test images shape: (10000, 1, 28, 28) - test labels shape: (10000, 10) - -### [mnist][mnist] - - * `mnist` - train images shape: (60000, 1, 28, 28) - train labels shape: (60000, 10) - test images shape: (10000, 1, 28, 28) - test labels shape: (10000, 10) +in alphabetical order, using default `mnists.prepare` parameters: [emnist]: //www.nist.gov/itl/iad/image-group/emnist-dataset [fashion-mnist]: //github.com/zalandoresearch/fashion-mnist [mnist]: http://yann.lecun.com/exdb/mnist/ + +| dataset | train images shape | train labels shape | test images shape | test labels shape | +| :--- | ---: | ---: | ---: | ---: | +| emnist\_balanced | (112800, 1, 28, 28) | (112800, 47) | (18800, 1, 28, 28) | (18800, 47) | +| emnist\_byclass | (697932, 1, 28, 28) | (697932, 62) | (116323, 1, 28, 28) | (116323, 62) | +| emnist\_bymerge | (697932, 1, 28, 28) | (697932, 47) | (116323, 1, 28, 28) | (116323, 47) | +| emnist\_digits | (240000, 1, 28, 28) | (240000, 10) | (40000, 1, 28, 28) | (40000, 10) | +| emnist\_letters | (124800, 1, 28, 28) | (124800, 26) | (20800, 1, 28, 28) | (20800, 26) | +| emnist\_mnist | (60000, 1, 28, 28) | (60000, 10) | (10000, 1, 28, 28) | (10000, 10) | +| fashion\_mnist | (60000, 1, 28, 28) | (60000, 10) | (10000, 1, 28, 28) | (10000, 10) | +| mnist | (60000, 1, 28, 28) | (60000, 10) | (10000, 1, 28, 28) | (10000, 10) | diff --git a/mnists/__main__.py b/mnists/__main__.py index 168f382..b9f3d8f 100644 --- a/mnists/__main__.py +++ b/mnists/__main__.py @@ -1,13 +1,23 @@ from . import metadata, prepare -names = ("train images", "train labels", "test images", "test labels") +headers = ("dataset", + "train images shape", + "train labels shape", + "test images shape", + "test labels shape") + +row = "| {:<20} | {:<20} | {:<20} | {:<20} | {:<20} |" + +separators = (":---", "---:", "---:", "---:", "---:") + +print(row.format(*headers)) +print(row.format(*separators)) for name in metadata.keys(): # verify every dataset, downloading if necessary. - # print out the shapes for use in the README. - print(f" * `{name}` ") + # print out the shape table for use in the README. data = prepare(name) - for name, dat in zip(names, data): - print(f" {name} shape: {dat.shape} ") - print() + row_data = [name.replace("_", "\\_")] + row_data += [str(array.shape) for array in data] + print(row.format(*row_data))