https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
I'm using Ubuntu 16.04 with a GTX 1060
from pathlib import Path | |
from fire import Fire | |
import torch | |
def main(model:str, outfile:str=None): | |
""" | |
Args: | |
model: path to neutone model file | |
outfile: path to write nn~ model file |
import heapq | |
class PQDItem: | |
def __init__(self, k, v): | |
self.v = v | |
self.k = k | |
self.dead = False | |
def __lt__(self, other): | |
return self.v < other.v |
import asyncio | |
def wrap_coroutine(coroutine): | |
def future(*a, **kw): | |
return asyncio.ensure_future(coroutine(*a, **kw)) | |
def sync(*a, **kw): | |
return asyncio.get_event_loop().run_until_complete(coroutine(*a, **kw)) | |
coroutine.sync = sync | |
coroutine.future = future | |
return coroutine |
'use strict'; | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, no catch'}); | |
(new Promise((resolve, reject) => { | |
resolve('success'); | |
})).then(x => {throw 'thrown error in then, with catch'}) | |
.catch(err => Promise.reject(err)); |
try: | |
from bokeh.io import push_notebook, output_notebook, show | |
from bokeh.plotting import figure | |
output_notebook() | |
def dynamic_image_figure(w,h): | |
"""create an RGB image figure in current cell and return an update function for it""" | |
def im2bokeh(img): | |
img = (img*255).astype(np.uint8) | |
img = np.dstack([img, np.ones(img.shape[:2], np.uint8) * 255]) | |
img = np.squeeze(img.view(np.uint32)) |
https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
I'm using Ubuntu 16.04 with a GTX 1060
from contextlib import contextmanager | |
import numpy as np | |
import torch | |
from torch import Tensor, ByteTensor | |
import torch.nn.functional as F | |
from torch.autograd import Variable | |
import pycuda.driver | |
from pycuda.gl import graphics_map_flags | |
from glumpy import app, gloo, gl |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.stats import norm, invgamma | |
# estimate a univariate gaussian by Gibbs sampling | |
true_mu = 10 | |
true_sigma = 2 | |
true_v = true_sigma**0.5 | |
N = 50 | |
R = 5000 |
running test | |
running egg_info | |
writing dependency_links to protobuf.egg-info/dependency_links.txt | |
writing protobuf.egg-info/PKG-INFO | |
writing namespace_packages to protobuf.egg-info/namespace_packages.txt | |
writing requirements to protobuf.egg-info/requires.txt | |
writing top-level names to protobuf.egg-info/top_level.txt | |
reading manifest file 'protobuf.egg-info/SOURCES.txt' | |
reading manifest template 'MANIFEST.in' | |
warning: no previously-included files found matching 'google/protobuf/internal/*.proto' |
Wolfram Alpha input to get polynomial approximation to function on an interval | |
for example to approximate exp(x) with ax^2 + bx + 1 on [0,1]: | |
solve (partial derivatives wrt a,b of (integral of (exp(x)-(ax^2 +bx+1))^2 from 0 to 1)) for a,b | |
or properly: | |
Solve[ D[ Integrate[ (exp(x)-(ax^2 +bx+1))^2, {x,0,1} ], {{a,b}} ] = 0, {a,b}] |