mnists/mnists/__main__.py

38 lines
1.0 KiB
Python
Raw Normal View History

2018-03-14 08:16:14 -07:00
from . import metadata, prepare
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/",
}
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]
row_data = [f"[{prefix}][]"]
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():
print(f"[{anchor}]: {url}")