This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Display Theano functions in the IPython notebook with pydotprint.""" | |
| __author__ = "David Warde-Farley" | |
| __copyright__ = "Copyright 2012, Universite de Montreal" | |
| __credits__ = ["David Warde-Farley"] | |
| __license__ = "3-clause BSD" | |
| __email__ = "wardefar@iro" | |
| __maintainer__ = "David Warde-Farley" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class KeyAwareDefaultDict(dict): | |
| """ | |
| Like a standard library defaultdict, but pass the key | |
| to the default factory. | |
| """ | |
| def __init__(self, default_factory=None): | |
| self.default_factory = default_factory | |
| def __getitem__(self, key): | |
| if key not in self and self.default_factory is not None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A matplotlib-based image viewer utility function. | |
| """ | |
| import matplotlib.pyplot as plt | |
| def image_view(arr, fig=None, frame_on=True, *args, **kwargs): | |
| """ | |
| Sensibly display an image in a plot window. | |
| Parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import theano | |
| import functools | |
| def cached_theano_function(fn): | |
| @functools.wraps(fn) | |
| def wrapped(self): | |
| if not hasattr(self, '_function_cache'): | |
| self._function_cache = {} | |
| if fn.func_name not in self._function_cache: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Parallelized k-means module. | |
| By David Warde-Farley, February 2012. Licensed under the 3-clause BSD. | |
| """ | |
| cimport cython | |
| from cython.parallel import prange | |
| import numpy as np | |
| cimport numpy as np | |
| from numpy.random import normal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Example of how to read a partial NumPy array stored in NPY | |
| format off of disk. | |
| """ | |
| __author__ = "David Warde-Farley" | |
| __copyright__ = "Copyright (c) 2012 by " + __author__ | |
| __license__ = "3-clause BSD" | |
| __email__ = "[email protected]" | |
| import struct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Copyright (c) 2009, David Warde-Farley | |
| # All rights reserved. | |
| # | |
| # Redistribution and use in source and binary forms, with or without | |
| # modification, are permitted provided that the following conditions | |
| # are met: | |
| # 1. Redistributions of source code must retain the above copyright | |
| # notice, this list of conditions and the following disclaimer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| L1-penalized minimization using the feature sign search algorithm. | |
| """ | |
| import logging | |
| import numpy as np | |
| log = logging.getLogger("feature_sign") | |
| log.setLevel(logging.INFO) |