This file contains 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
alias deltrace ipdb.set_trace = lambda: None | |
alias pshape (%1).shape | |
alias plen len(%1) | |
alias plshape for i in (%1): print(i.shape) | |
alias embed import IPython; IPython.embed() | |
alias ts from pprint import pprint; from pdbhelpers import tensor_shapes; A=tensor_shapes(%1); pprint(A) |
This file contains 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 sys | |
import click | |
import shelve | |
import datetime | |
from prompt_toolkit.validation import Validator, ValidationError | |
from prompt_toolkit import prompt | |
class NumberValidator(Validator): | |
def validate(self, document): | |
text = document.text |
This file contains 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
#include <algorithm> | |
#include <numeric> | |
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
#include "boost/multi_array.hpp" | |
template<class T, long unsigned int D=2u> | |
boost::multi_array<T, D> fromfile(std::string f, bool convert_to_c_order=false){ | |
typedef boost::multi_array<T, D> array_type; |
This file contains 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 numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.datasets import fetch_mldata | |
from sklearn.decomposition import FastICA, PCA | |
from sklearn.cluster import KMeans | |
# fetch natural image patches | |
image_patches = fetch_mldata("natural scenes data") | |
X = image_patches.data |
This file contains 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
#cython: boundscheck=False | |
#cython: cdivision=True | |
#cython: wraparound=False | |
# While learning about Cython, I found code which proudly adds | |
# 'nogil' to function heads wherever possible. | |
# | |
# In the generated C-Code, the effect is mainly three lines: | |
# | |
# |
This file contains 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
# Create a random palette in LAB space and convert to RGB. | |
# For easy use as a infinite colormap in matplotlib. | |
# After an idea from @amueller and | |
# http://stackoverflow.com/questions/10254207/color-and-line-writing-using-matplotlib | |
import numpy as np | |
from colormath.color_objects import LabColor | |
def get_random_color(seed=3): |