Skip to content

Commit 62e139c

Browse files
Merge pull request #3742 from akorgor/fix-nmnist-download
Update N-MNIST download URL and robustify download method in e-prop tutorial
2 parents 1daac7b + fff9113 commit 62e139c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

pynest/examples/eprop_plasticity/eprop_supervised_classification_neuromorphic_mnist.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def unzip(zip_file_path, extraction_path):
473473

474474
def download_and_extract_nmnist_dataset(save_path="./"):
475475
nmnist_dataset = {
476-
"url": "https://prod-dcd-datasets-cache-zipfiles.s3.eu-west-1.amazonaws.com/468j46mzdv-1.zip",
476+
"url": "https://data.mendeley.com/public-api/zip/468j46mzdv/download/1",
477477
"directory": "468j46mzdv-1",
478478
"zip": "dataset.zip",
479479
}
@@ -488,9 +488,13 @@ def download_and_extract_nmnist_dataset(save_path="./"):
488488
if not (os.path.exists(path) and os.path.exists(train_path) and os.path.exists(test_path)):
489489
if not os.path.exists(downloaded_zip_path):
490490
print("\nDownloading the N-MNIST dataset.")
491-
response = requests.get(nmnist_dataset["url"], timeout=10)
492-
with open(downloaded_zip_path, "wb") as file:
493-
file.write(response.content)
491+
chunk_size = 1024 * 1024 # 1 MiB
492+
with requests.get(nmnist_dataset["url"], stream=True, timeout=60) as r:
493+
r.raise_for_status()
494+
with open(downloaded_zip_path, "wb", buffering=chunk_size) as f:
495+
for chunk in r.iter_content(chunk_size=chunk_size):
496+
if chunk:
497+
f.write(chunk)
494498

495499
unzip(downloaded_zip_path, save_path)
496500
unzip(f"{train_path}.zip", path)

0 commit comments

Comments
 (0)