def log_queue(log_to=None): if log_to: # standard logfile jlog = munk.file_sink(log_to+".log") jlog = munk.jsonify(jlog) jlog = munk.timify(jlog, tag="timestamp") jlog = munk.exclude(jlog, "params") # parameter logfile paraml = munk.file_sink(log_to+".params") paraml = munk.jsonify(paraml) paraml = munk.timify(paraml, tag="timestamp") paraml = munk.include(paraml, "params") jplog = munk.broadcast(*[jlog, paraml]) # finally a pretty printer for some immediate feedback pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") pp = munk.include_tags_only(pp, "pretty") jplog = munk.exclude_tags(jplog, "pretty") log = munk.broadcast(*[jplog, pp]) else: pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") log = munk.include_tags_only(pp, "pretty") return log
def log_queue(log_to=None): if log_to: # standard logfile jlog = munk.file_sink(log_to + ".log") jlog = munk.jsonify(jlog) jlog = munk.timify(jlog, tag="timestamp") jlog = munk.exclude(jlog, "params") # parameter logfile paraml = munk.file_sink(log_to + ".params") paraml = munk.jsonify(paraml) paraml = munk.timify(paraml, tag="timestamp") paraml = munk.include(paraml, "params") jplog = munk.broadcast(*[jlog, paraml]) # finally a pretty printer for some immediate feedback pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") pp = munk.include_tags_only(pp, "pretty") jplog = munk.exclude_tags(jplog, "pretty") log = munk.broadcast(*[jplog, pp]) else: pp = munk.timify(munk.prettyprint_sink()) pp = munk.dontkeep(pp, "tags") log = munk.include_tags_only(pp, "pretty") return log
def test_broadcast(): lst1 = [] lst2 = [] pipe1 = L.list_sink(lst1) pipe2 = L.list_sink(lst2) pipe = L.broadcast(pipe1, pipe2) info = {'und alle so': 'yeah'} pipe.send(info) assert lst1[0] == info, 'list 1 did not receive info' assert lst2[0] == info, 'list 2 did not receive info'
## for i, info in enumerate(checker): ## print "errors in gradient", info['errors'] ## if i>0: ## break import chopmunk ignore = ['args', 'kwargs', 'gradient', 'Hp'] console_sink = chopmunk.prettyprint_sink() console_sink = chopmunk.dontkeep(console_sink, ignore) file_sink = chopmunk.file_sink('mnist.log') file_sink = chopmunk.jsonify(file_sink) file_sink = chopmunk.dontkeep(file_sink, ignore) logger = chopmunk.broadcast(console_sink, file_sink) logfunc = logger.send #size of blocks used for the diagonal approximation blocksizes = np.ones(n_hidden + n_output) blocksizes[:n_hidden] *= (n_inpt+1) blocksizes[n_hidden:] *= (n_hidden+1) opt = tonga(P.data, fprime, damping=1e-2, blocksizes=blocksizes, nb_estimates=50, args=args, cov_args=cov_args, logfunc=logfunc) fileName = 'testTonga2' fileLog = open(fileName, 'w') fileLog.write('') fileLog.close()