import random import ipdb domains = ["clipart", "infograph", "painting", "quickdraw", "real", "sketch"] random.seed(42) data = [] for index, domain in enumerate(domains): with open(domain + '_train_fold.txt', 'r') as f: domain_data = f.readlines() domain_data = [x.strip() + ' ' + str(index) + '\n' for x in domain_data] data.extend(domain_data) random.shuffle(data) data = data[:30000] with open('Domainnet_train_30k.txt', 'w') as f: f.write("".join(data))