Mercurial > pylearn
view pylearn/dataset_ops/memo.py @ 1476:8c10bda4bb5f
Configured default train/valid/test split for icml07.MNIST_rotated_background
dataset. Defaults are the ones used by Hugo in the ICML07 paper and in all
contracting auto-encoder papers.
author | gdesjardins |
---|---|
date | Fri, 20 May 2011 16:53:00 -0400 |
parents | c9ec065ff736 |
children |
line wrap: on
line source
"""Provide a decorator that caches expensive functions """ import logging _logger = logging.getLogger(__file__) info = _logger.info def infop(*args): info(' '.join(str(a) for a in args)) def memo(f): #TODO: support kwargs to rval. This requires looking up the names of f's parameters to # construct a proper key. cache = {} def rval(*args): if args not in cache: cache[args] = f(*args) return cache[args] def forget(): for k in cache.keys(): del cache[k] rval.cache = cache rval.forget = forget rval.__name__ = 'memo@%s'%f.__name__ rval.cache = cache rval.__doc__ = f.__doc__ return rval