debug the training process, initialize a nameserver if no nameserver exists
This commit is contained in:
parent
5c29dad263
commit
2b1285143c
@ -203,7 +203,8 @@ class ResNet(object):
|
|||||||
iters = 0
|
iters = 0
|
||||||
while True:
|
while True:
|
||||||
new_file_list = list(set(os.listdir(data_path)).difference(all_file_list))
|
new_file_list = list(set(os.listdir(data_path)).difference(all_file_list))
|
||||||
all_file_list = os.listdir(data_path)
|
if new_file_list:
|
||||||
|
all_file_list = os.listdir(data_path)
|
||||||
new_file_list.sort(
|
new_file_list.sort(
|
||||||
key=lambda file: os.path.getmtime(data_path + file) if not os.path.isdir(data_path + file) else 0)
|
key=lambda file: os.path.getmtime(data_path + file) if not os.path.isdir(data_path + file) else 0)
|
||||||
if new_file_list:
|
if new_file_list:
|
||||||
@ -241,8 +242,16 @@ class ResNet(object):
|
|||||||
self.saver.save(self.sess, self.checkpoint_path + save_path)
|
self.saver.save(self.sess, self.checkpoint_path + save_path)
|
||||||
|
|
||||||
def _file_to_training_data(self, file_name):
|
def _file_to_training_data(self, file_name):
|
||||||
with open(file_name, 'r') as file:
|
read = False
|
||||||
data = cPickle.load(file)
|
with open(file_name, 'rb') as file:
|
||||||
|
while not read:
|
||||||
|
try:
|
||||||
|
file.seek(0)
|
||||||
|
data = cPickle.load(file)
|
||||||
|
read = True
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
time.sleep(1)
|
||||||
history = deque(maxlen=self.history_length)
|
history = deque(maxlen=self.history_length)
|
||||||
states = []
|
states = []
|
||||||
probs = []
|
probs = []
|
||||||
|
@ -50,6 +50,12 @@ if __name__ == '__main__':
|
|||||||
# print "Start Name Sever : " + str(start_new_server.pid) # + str(start_new_server.wait())
|
# print "Start Name Sever : " + str(start_new_server.pid) # + str(start_new_server.wait())
|
||||||
# time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
|
# start a name server if no name server exists
|
||||||
|
if len(os.popen('ps aux | grep pyro4-ns | grep -v grep').readlines()) == 0:
|
||||||
|
start_new_server = subprocess.Popen(['pyro4-ns', '&'])
|
||||||
|
print "Start Name Sever : " + str(start_new_server.pid) # + str(start_new_server.wait())
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
# start two different player with different network weights.
|
# start two different player with different network weights.
|
||||||
black_role_name = 'black' + str(args.id)
|
black_role_name = 'black' + str(args.id)
|
||||||
white_role_name = 'white' + str(args.id)
|
white_role_name = 'white' + str(args.id)
|
||||||
@ -137,13 +143,13 @@ if __name__ == '__main__':
|
|||||||
file_list.sort(key=lambda file: os.path.getmtime(args.result_path + file) if not os.path.isdir(
|
file_list.sort(key=lambda file: os.path.getmtime(args.result_path + file) if not os.path.isdir(
|
||||||
args.result_path + file) else 0)
|
args.result_path + file) else 0)
|
||||||
data_num = eval(file_list[-1][:-4]) + 1
|
data_num = eval(file_list[-1][:-4]) + 1
|
||||||
with open("./data/" + str(data_num) + ".pkl", "w") as file:
|
with open("./data/" + str(data_num) + ".pkl", "wb") as file:
|
||||||
picklestring = cPickle.dump(data, file)
|
picklestring = cPickle.dump(data, file)
|
||||||
data.reset()
|
data.reset()
|
||||||
game_num += 1
|
game_num += 1
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
subprocess.call(["kill", "-9", str(agent_v0.pid)])
|
subprocess.call(["kill", "-9", str(agent_v0.pid)])
|
||||||
subprocess.call(["kill", "-9", str(agent_v1.pid)])
|
subprocess.call(["kill", "-9", str(agent_v1.pid)])
|
||||||
print "Kill all player, finish all game."
|
print "Kill all player, finish all game."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user