mnists/mnists/__main__.py

44 lines
1.2 KiB
Python
Raw Normal View History

import logging
2018-03-14 08:16:14 -07:00
from . import metadata, prepare, logger
logging.basicConfig()
logger.setLevel(logging.DEBUG)
2018-03-14 08:16:14 -07:00
2018-03-23 22:42:29 -07:00
headers = ("subdirectory",
"dataset",
2018-03-14 18:10:28 -07:00
"train images shape",
"train labels shape",
"test images shape",
"test labels shape")
2018-03-23 22:42:29 -07:00
row = "| {:<20} | {:<20} | {:<20} | {:<20} | {:<20} | {:<20} |"
2018-03-14 18:10:28 -07:00
2018-03-23 22:42:29 -07:00
separators = (":---", ":---", "---:", "---:", "---:", "---:")
urls = {
"emnist": "//www.nist.gov/itl/iad/image-group/emnist-dataset",
"fashion-mnist": "//github.com/zalandoresearch/fashion-mnist",
"mnist": "http://yann.lecun.com/exdb/mnist/",
2020-03-30 10:41:09 -07:00
"qmnist": "//github.com/facebookresearch/qmnist",
2018-03-23 22:42:29 -07:00
}
2018-03-14 18:10:28 -07:00
print(row.format(*headers))
print(row.format(*separators))
2018-03-14 17:44:40 -07:00
2018-03-14 08:16:14 -07:00
for name in metadata.keys():
2018-03-14 17:44:40 -07:00
# verify every dataset, downloading if necessary.
2018-03-14 18:10:28 -07:00
# print out the shape table for use in the README.
2018-03-14 17:44:40 -07:00
data = prepare(name)
2018-03-23 22:42:29 -07:00
prefix = metadata[name][0]
2018-03-24 03:46:57 -07:00
row_data = ["[{}][]".format(prefix)]
2018-03-23 22:42:29 -07:00
row_data += [name.replace("_", "\\_")]
2018-03-14 18:10:28 -07:00
row_data += [str(array.shape) for array in data]
print(row.format(*row_data))
2018-03-23 22:42:29 -07:00
print()
for anchor, url in urls.items():
2018-03-24 03:46:57 -07:00
print("[{}]: {}".format(anchor, url))