File size: 571 Bytes
0a1bf92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))