This repository was archived by the owner on Dec 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_count.py
More file actions
56 lines (38 loc) · 1.42 KB
/
patch_count.py
File metadata and controls
56 lines (38 loc) · 1.42 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
53
54
55
56
from time import time
from glob import glob
import tensorflow as tf
from clustering.import_stage import build_id_import_stage
def main():
with tf.Graph().as_default() as import_graph:
all_files = glob('data/00238.tfrecord.gz')
t_inputs = build_id_import_stage(all_files)
coord = tf.train.Coordinator()
with tf.Session(graph=import_graph) as sess:
sess.run(tf.group(tf.local_variables_initializer(), tf.global_variables_initializer()))
threads = tf.train.start_queue_runners(coord=coord, sess=sess)
iteration = 0
total_count = 0
start_time = time()
iid = 0
pid = 0
try:
while not coord.should_stop():
iteration += 1
inputs = sess.run(t_inputs)
iid = max(iid, inputs[0])
pid = max(pid, inputs[1])
batch_size = inputs.shape[0]
total_count += batch_size
if time() - start_time >= 10.:
start_time = time()
print('Current count: %i' % total_count)
except tf.errors.OutOfRangeError:
print('Training done after iteration %i' % (iteration-1))
finally:
coord.request_stop()
coord.join(threads)
print('Final count: %i' % total_count)
print('IID %i. PID %i' % (iid, pid))
pass
if __name__ == '__main__':
main()