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
| In [87]: A, B = np.ones((1, 2)), np.random.random((3, 3, 1)) | |
| In [88]: B | |
| Out[88]: | |
| array([[[ 0.02738198], | |
| [ 0.23332334], | |
| [ 0.12513209]], | |
| [[ 0.48753864], | |
| [ 0.45401342], |
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 | |
| import numpy | |
| import time | |
| try: | |
| import numpy.core._dotblas | |
| print 'Using ATLAS:' | |
| except ImportError: | |
| print 'No ATLAS:' | |
| print numpy.__version__ |
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 | |
| import numpy | |
| import time | |
| import sys | |
| N = int(sys.argv[1]) | |
| try: | |
| import numpy.core._dotblas | |
| print 'Using ATLAS:' |
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
| X = predicted position | |
| Z = true position | |
| lds = our learned lds on [X, Z] | |
| # Get marginal LDS | |
| marginal_lds = marginal(lds, (7, 8, 9, 10, 11, 12, 13)) # | |
| # Compile a function to calculate hidden state given position predictions. | |
| f = marginal_lds.function(['inpt'], ['filtered_means']) |
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 spearmint | |
| exp = spearmint.Experiment() | |
| exp.add_variable('n_hiddens', min=1, max=100, type=int) | |
| for i in range(100): # Do 100 trials. | |
| id, args = exp.draw() # Get a new candidate; id is used as a handle for later pushing back results into the experiment. | |
| cost = f(args) # Evaluate objective. | |
| exp.push(id, cost) # Push results into the experiment so we get a new candidate based on those results in the next iteration. |
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.tensor as T | |
| x = T.matrix() | |
| c = T.matrix() | |
| s = T.switch(c, x, 0) | |
| l = s.sum() | |
| T.grad(l, x) # Assertion error... |
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
| from IPython.core.display import Image as image | |
| from PIL import Image | |
| def save_and_display(arr, fname): | |
| pilimg = Image.fromarray(arr) | |
| pilimg.save(fname) | |
| return image(filename=fname, width=600) |
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
| In [1]: from collections import namedtuple | |
| In [3]: p = namedtuple('p', ['bla']) | |
| In [4]: pp = p(2) | |
| In [5]: pp | |
| Out[5]: p(bla=2) | |
| In [6]: import pickle | |
| In [7]: pickle.dumps(pp) | |
| Out[7]: 'ccopy_reg\n_reconstructor\np0\n(c__main__\np\np1\nc__builtin__\ntuple\np2\n(I2\ntp3\ntp4\nRp5\n.' |
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
| --------------------------------------------------------------------------- | |
| ValueError Traceback (most recent call last) | |
| <ipython-input-4-f143d352e435> in <module>() | |
| ----> 1 filtered = mean_filter(X, 10) | |
| /Users/bayerj/anaconda/lib/python2.7/site-packages/numba/decorators.pyc in __call__(self, *args, **kwargs) | |
| 162 raise error.NumbaError("Expected %d arguments, got %d" % ( | |
| 163 nargs, len(args))) | |
| --> 164 return self.wrapper(self, *args, **kwargs) | |
| 165 |
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
| tmp ❯❯❯ py importtheano.py | |
| Vendor: continuumProduct: anacondapro | |
| Message: trial mode expires in 27 days | |
| WARNING (theano.gof.compilelock): Overriding existing lock by dead process '82054' (I am process '82104') | |
| > /Users/bayerj/devel/Theano/theano/gof/cmodule.py(264)dlimport() | |
| -> try: | |
| (Pdb) s | |
| > /Users/bayerj/devel/Theano/theano/gof/cmodule.py(265)dlimport() | |
| -> print module_name | |
| (Pdb) s |