Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def test_jsonify():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.jsonify(pipe)
    info = {'2': [3], '4': 5.}
    pipe.send(info)
    received_info = json.loads(lst[0])
    assert received_info == info, 'jsonify did mutate info: %s' % received_info
Exemplo n.º 4
0
## import numericalGradientChecker

## checker = numericalGradientChecker.numericalGradientChecker(fraw, fprime, inputDim=P.data.size, outputDim=batchsize, args=args, bounds=None)
## 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'