import random | |
domains = ["clipart", "infograph", "painting", "quickdraw", "real", "sketch"] | |
random.seed(42) | |
for domain in domains: | |
with open(domain + '_train.txt', 'r') as f: | |
domain_data = f.readlines() | |
random.shuffle(domain_data) | |
valid_data = domain_data[0:int(len(domain_data)*0.2)] | |
train_data = domain_data[int(len(domain_data)*0.2):] | |
with open(domain + '_train_fold.txt', 'w') as f: | |
f.write("".join(train_data)) | |
with open(domain + '_valid_fold.txt', 'w') as f: | |
f.write("".join(valid_data)) |