-
-
Save ry/6a284a67eb0118f97b97889ee0309e76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os.path | |
import numpy as np | |
n = int(sys.argv[1]) | |
assert 1 < n < 100 | |
fn = sys.argv[2] | |
pattern = fn.rsplit(".", 1)[0] + "_%02d.npy" | |
x = np.load(fn) | |
nx = x.shape[0] / n | |
assert(x.shape[0] % n == 0); | |
print "examples per shard", nx | |
for i in range(n): | |
sfn = pattern % i | |
s = x[nx*i: nx*(i+1)] | |
np.save(sfn, s) | |
print i, sfn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment