示例#1
0
文件: utils.py 项目: afcarl/gpustack
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
示例#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
示例#3
0
文件: test.py 项目: bayerj/chopmunk
def test_dontkeep():
    lst = []
    pipe = L.list_sink(lst)
    pipe = L.dontkeep(pipe, ['blabla'])

    pipe.send({'message': 'take care', 'blabla': 'blubb'})

    assert len(lst) == 1, 'wrong number of messages got through'
    assert lst[0] == {'message': 'take care'}, 'wrong keys got through'
示例#4
0
文件: utils.py 项目: afcarl/gpustack
def reload(depot, folder, tag, layer):
    """
    """
    import notebook as nb
    model, schedule = nb.reload(depot, folder, tag, layer)

    log = munk.prettyprint_sink()
    log = munk.dontkeep(log, "tags")
    log = munk.include_tags_only(log, "pretty")

    schedule['logging'] = log

    lab = schedule['__lab__']
    lab = __import__(lab.split('.')[0])
    lab.no_training(model, schedule)
示例#5
0
def reload(depot, folder, tag, layer):
    """
    """
    import notebook as nb
    model, schedule = nb.reload(depot, folder, tag, layer)

    log = munk.prettyprint_sink()
    log = munk.dontkeep(log, "tags")
    log = munk.include_tags_only(log, "pretty")

    schedule['logging'] = log

    lab = schedule['__lab__']
    lab = __import__(lab.split('.')[0])
    lab.no_training(model, schedule)
示例#6
0
print '#pars:', P.data.size

## 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)