MCPcopy Create free account
hub / github.com/TrustAIResearch/MLHospital / count_dataset

Function count_dataset

mlh/data_preprocessing/dataset_preprocessing.py:31–64  ·  view source on GitHub ↗
(targetTrainloader, targetTestloader, shadowTrainloader, shadowTestloader, num_classes, attr=None)

Source from the content-addressed store, hash-verified

29
30
31def count_dataset(targetTrainloader, targetTestloader, shadowTrainloader, shadowTestloader, num_classes, attr=None):
32 target_train = [0 for i in range(num_classes)]
33 target_test = [0 for i in range(num_classes)]
34 shadow_train = [0 for i in range(num_classes)]
35 shadow_test = [0 for i in range(num_classes)]
36
37 for _, num in targetTrainloader:
38 if attr != None:
39 num = num[attr]
40 for row in num:
41 target_train[int(row)] += 1
42
43 for _, num in targetTestloader:
44 if attr != None:
45 num = num[attr]
46 for row in num:
47 target_test[int(row)] += 1
48
49 for _, num in shadowTrainloader:
50 if attr != None:
51 num = num[attr]
52 for row in num:
53 shadow_train[int(row)] += 1
54
55 for _, num in shadowTestloader:
56 if attr != None:
57 num = num[attr]
58 for row in num:
59 shadow_test[int(row)] += 1
60
61 print(target_train)
62 print(target_test)
63 print(shadow_train)
64 print(shadow_test)
65
66
67def prepare_dataset(dataset, select_num=None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected