Instantly share code, notes, and snippets.

• Sort options
Created May 22, 2017
Plancherel's theorem
View test.py
 import numpy as np np.set_printoptions(precision=3, linewidth=200) a = np.random.normal(size=(3, 3)) q, _ = np.linalg.qr(a) print(np.matmul(q, q.T)) s = np.fft.fft2(q) print(np.matmul(s, s.conj().T))
Created Oct 18, 2016
View solve.py
 from sympy import Symbol, init_printing from sympy.solvers import solve from IPython.display import display init_printing() x1 = Symbol('x1') x2 = Symbol('x2') y = Symbol('y')
Created Oct 5, 2016
bilinear_bug.lua
View gist:e31f9bafee2a85243f1d4714fd3cb1ff
 require('nn') require('nngraph') local m do local x1, x2 = nn.Identity()(), nn.Identity()() local y = nn.Bilinear(2, 2, 2){x1, x2} m = nn.gModule({x1, x2}, {y}) end
Last active Feb 15, 2016
Converts a human-readable memory string (e.g. "256 GiB") into an integral byte count.
View parse_memory_string.py
 import re def parse_memory_string(mem_str): """ Returns the number of bytes represented by a string ``mem_str`` matching the following regex: :: r'^(0|[1-9][0-9]*) (byte|bytes|KiB|MiB|GiB|TiB)' If ``mem_str`` does not match this regex, then ``None`` is returned.
Last active Aug 29, 2015
A simple "Hello, world" program using Mach threads.