def __init__(self, load=None, **kwargs): if load is None: args = {} else: args = util.load_params(load, 'train') util.update(args, mode=RL.Mode.TRAIN, **kwargs) print(args) Default.__init__(self, **args) if self.init: self.model.init() self.model.save() else: self.model.restore() context = zmq.Context.instance() self.experience_socket = context.socket(zmq.PULL) experience_addr = "tcp://%s:%d" % ( self.dump, util.port(self.model.name + "/experience")) self.experience_socket.bind(experience_addr) self.params_socket = context.socket(zmq.PUB) params_addr = "tcp://%s:%d" % (self.dump, util.port(self.model.name + "/params")) print("Binding params socket to", params_addr) self.params_socket.bind(params_addr) self.sweep_size = self.batches * self.batch_size print("Sweep size", self.sweep_size) self.buffer = util.CircularQueue(self.sweep_size) self.last_save = time.time()
def __init__(self, load=None, **kwargs): if load is None: args = {} else: args = util.load_params(load, 'train') util.update(args, mode=RL.Mode.TRAIN, **kwargs) util.pp.pprint(args) Default.__init__(self, **args) addresses = netifaces.ifaddresses(self.dump) address = addresses[netifaces.AF_INET][0]['addr'] with open(os.path.join(self.model.path, 'ip'), 'w') as f: f.write(address) context = zmq.Context.instance() self.experience_socket = context.socket(zmq.PULL) experience_addr = "tcp://%s:%d" % ( address, util.port(self.model.name + "/experience")) self.experience_socket.bind(experience_addr) if self.send: import nnpy self.params_socket = nnpy.Socket(nnpy.AF_SP, nnpy.PUB) params_addr = "tcp://%s:%d" % ( address, util.port(self.model.name + "/params")) print("Binding params socket to", params_addr) self.params_socket.bind(params_addr) self.sweep_size = self.batches * self.batch_size print("Sweep size", self.sweep_size) if self.init: self.model.init() self.model.save() else: self.model.restore() self.last_save = time.time()
def __init__(self, load=None, **kwargs): if load is None: args = {} else: args = util.load_params(load, 'train') util.update(args, **kwargs) util.pp.pprint(args) Default.__init__(self, **args) addresses = netifaces.ifaddresses(self.dump) address = addresses[netifaces.AF_INET][0]['addr'] util.makedirs(self.learner.path) with open(os.path.join(self.learner.path, 'ip'), 'w') as f: f.write(address) self.experience_socket = nnpy.Socket(nnpy.AF_SP, nnpy.PULL) experience_addr = "tcp://%s:%d" % ( address, util.port(self.learner.path + "/experience")) self.experience_socket.bind(experience_addr) if self.send: self.params_socket = nnpy.Socket(nnpy.AF_SP, nnpy.PUB) params_addr = "tcp://%s:%d" % ( address, util.port(self.learner.path + "/params")) print("Binding params socket to", params_addr) self.params_socket.bind(params_addr) self.sweep_size = self.batch_size print("Sweep size", self.sweep_size) if self.init: self.learner.init() self.learner.save() else: self.learner.restore() self.last_save = time.time()