-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstant_batch_size.py
More file actions
59 lines (35 loc) · 1.46 KB
/
constant_batch_size.py
File metadata and controls
59 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from batching_techniques import batch_stop4,batch_divide4,batch_bisect,back_to_one,pool_testing
class ConstantBatching():
def __init__(self,batch,batch_size=4,method='batch_stop4'):
self.batch=batch
self.batch_size=batch_size
self.method=method
self.disspatcher_batching_technique={'batch_stop4':batch_stop4,'batch_bisect':batch_bisect,'batch_divide4':batch_divide4,'back_to_one':back_to_one, 'pool_testing':pool_testing}
@staticmethod
def runbatch(batch):
for test in batch:
if (test == False):
return False
return True
def run(self):
test_number=0
batch_size=self.batch_size
counter = 0
flag = True
i = 0
while (flag):
i = i + 1
test_number = test_number + 1
slicebatch = self.batch[counter:(counter + batch_size)]
counter = counter + batch_size
if (self.runbatch(slicebatch) == False and batch_size != 1):
test_number+=self.disspatcher_batching_technique[self.method](slicebatch)
# test_number+=self.disspatcher[self.method](slicebatch)
# if (slicebatch[-1] == False):
# if (self.method== "back_to_one"):
# batch_size = 1
# else:
# batch_size = self.batch_size
if (counter >= len(self.batch)):
flag = False
return test_number