def save_figure(self): global _curr_logfile global _num_logfile_entries dir = ensure_dir(os.path.splitext(_curr_logfile)[0]) filename = dir + ('/img-%05d-%02d.png' % (_num_logfile_entries,self._unique_id)) tempname = dir + ('/img-%05d-%02d-%%s.png' % (_num_logfile_entries,self._unique_id)) self._unique_id += 1 # First save the individual Figure canvases to files pnames = ('errors','feat_in','feat_out','wstats','hstats','recons_tr','recons_te','activity1','activity2','activity3') fnames = [] for pname in pnames: if self.plots.has_key(pname): fnames.append(tempname % pname) plot = self.plots[pname] plot.redraw() plot.savefig(fnames[-1],dpi=80) # Then use ImageMagick to put them together again cmd = 'montage' for fname in fnames: cmd += ' ' + fname cmd += ' -tile 2x2 -geometry +0+0 ' + filename os.system(cmd) # And delete the temporary images of separate parts of the overall figure for fname in fnames: os.remove(fname) return filename
def save_figure(self): global _curr_logfile global _num_logfile_entries dir = ensure_dir(os.path.splitext(_curr_logfile)[0]) filename = dir + ("/img-%05d-%02d.png" % (_num_logfile_entries, self._unique_id)) tempname = dir + ("/img-%05d-%02d-%%s.png" % (_num_logfile_entries, self._unique_id)) self._unique_id += 1 # First save the individual Figure canvases to files pnames = ("errors", "feat_in", "feat_out", "wstats", "hstats") fnames = [] for pname in pnames: if self.plots.has_key(pname): fnames.append(tempname % pname) plot = self.plots[pname] plot.redraw() plot.savefig(fnames[-1], dpi=80) # Then use ImageMagick to put them together again cmd = "montage" for fname in fnames: cmd += " " + fname cmd += " -tile 2x2 -geometry +0+0 " + filename os.system(cmd) # And delete the temporary images of separate parts of the overall figure for fname in fnames: os.remove(fname) return filename
def open_logfile(prefix='train',msg=""): global _curr_logfile global _num_logfile_entries global _best_logfile_errors global _logs_dir dir = ensure_dir(_logs_dir) _curr_logfile = "%s/%s-%s.html" % (dir,prefix,time.strftime("%m%d%H%M",time.localtime())) with open(_curr_logfile,"w") as f: f.write("<html><head><title>%s</title></head>\n<body>\n" % _curr_logfile) f.write("<center style='font-size:120%%'>%s</center>\n" % _curr_logfile) f.write("<center style='font-size:120%%'>%s</center>\n" % msg) f.flush() f.close() _num_logfile_entries = 0 _best_logfile_errors = {} return _curr_logfile
def open_logfile(prefix="train", msg=""): global _curr_logfile global _num_logfile_entries global _best_logfile_errors global _logs_dir dir = ensure_dir(_logs_dir) _curr_logfile = "%s/%s-%s.html" % (dir, prefix, time.strftime("%m%d%H%M", time.localtime())) with open(_curr_logfile, "w") as f: f.write("<html><head><title>%s</title></head>\n<body>\n" % _curr_logfile) f.write("<center style='font-size:120%%'>%s</center>\n" % _curr_logfile) f.write("<center style='font-size:120%%'>%s</center>\n" % msg) f.flush() f.close() _num_logfile_entries = 0 _best_logfile_errors = {} return _curr_logfile