def progress(steps, elapsed): print '{} of {} processed ({} s)'.format(steps, len(queries), elapsed) util.metadata('steps', steps) util.metadata('gb_used', util.gb_used()) sys.stdout.flush() f.flush()
def control(self, experiment): if experiment.epochs >= self.max_epochs: print 'Halted after reaching max epochs.' experiment.halt = True if experiment.steps % self.report_wait == 0: print 'steps: {}, epochs: {:.2f}'.format(experiment.steps, experiment.epochs) util.metadata('steps', experiment.steps, self.path) util.metadata('epochs', experiment.epochs, self.path) # report last seen time_rep = datetime.now().strftime('%H:%M:%S %m/%d') util.metadata('last_seen', time_rep, self.path) # report memory used util.metadata('gb_used', util.gb_used(), self.path) if experiment.steps % self.save_wait == 0 and experiment.steps != 0: print 'saving params...' experiment.model.save_model(self.path)
def control(self, maximizer): if maximizer.steps >= self.max_steps: print 'Halted after reaching max steps.' maximizer.halt = True if maximizer.steps % self.report_wait == 0: epochs = float(maximizer.steps * maximizer.batch_size) / len(maximizer.train) print 'steps: {}, epochs: {:.2f}'.format(maximizer.steps, epochs) util.metadata('steps', maximizer.steps) util.metadata('epochs', epochs) # report last seen time_rep = datetime.now().strftime('%H:%M:%S %m/%d') util.metadata('last_seen', time_rep) # report memory used util.metadata('gb_used', util.gb_used()) if maximizer.steps % self.save_wait == 0 and maximizer.steps != 0: print 'saving params...' with open('params.cpkl', 'w') as f: # convert params to picklable format params = SparseVector(maximizer.params.as_dict()) pickle.dump(params, f)
def control(self, maximizer): if maximizer.steps >= self.max_steps: print "Halted after reaching max steps." maximizer.halt = True if maximizer.steps % self.report_wait == 0: epochs = float(maximizer.steps * maximizer.batch_size) / len(maximizer.train) print "steps: {}, epochs: {:.2f}".format(maximizer.steps, epochs) util.metadata("steps", maximizer.steps) util.metadata("epochs", epochs) # report last seen time_rep = datetime.now().strftime("%H:%M:%S %m/%d") util.metadata("last_seen", time_rep) # report memory used util.metadata("gb_used", util.gb_used()) if maximizer.steps % self.save_wait == 0 and maximizer.steps != 0: print "saving params..." with open("params.cpkl", "w") as f: # convert params to picklable format params = SparseVector(maximizer.params.as_dict()) pickle.dump(params, f)