-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (36 loc) · 1.18 KB
/
main.py
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
import tensorflow as tf
import numpy as np
import threading
import gym
import os
import multiprocessing
from scipy.misc import imresize
from tensorboardX import SummaryWriter
import a3c
import async_agent
def main():
tf.reset_default_graph()
sess = tf.InteractiveSession()
coord = tf.train.Coordinator()
n_threads = multiprocessing.cpu_count()
input_shape = [80, 80, 4]
output_dim = 3 # {1, 2, 3}
global_network = a3c.A3CNetwork(name="global",
input_shape=input_shape,
output_dim=output_dim)
thread_list = []
for id in range(n_threads):
single_agent = async_agent.Agent(
session=sess,
coord=coord,
name="thread_{}".format(id),
global_network=global_network,
input_shape=input_shape,
output_dim=output_dim)
thread_list.append(single_agent)
init = tf.global_variables_initializer()
sess.run(init)
for t in thread_list:
t.start()
if __name__ == '__main__':
main()