Skip to content

Instantly share code, notes, and snippets.

@braingineer
braingineer / doit.py
Last active April 29, 2016 23:52
3dim tensor, indexed by 3dim tensor, into 2nd dim
import theano.tensor as T
import theano
from theano import shared as S
import numpy as np
'''
meant to be run in an ipython notebook
'''
def f():
@braingineer
braingineer / sideloadingtensors.py
Last active May 4, 2016 23:50
trying to load shared variables on keras
'''
use as:
some_data = DataLayer(K.variable(some_tensor,dtype=whatever), ...)
next_layer = Dense(some_number)
out_tensor = next_layer(some_data.tensor)
'''
class DataLayer(Layer):
'''TODO: dosctring
'''
def __init__(self, input_tensor, input_dtype=None, name=None):
@braingineer
braingineer / lambdawithmask.py
Last active March 10, 2021 09:47
keras lambda layer supporting masking
class Lambda(Layer):
'''Used for evaluating an arbitrary Theano / TensorFlow expression
on the output of the previous layer.
# Examples
```python
# add a x -> x^2 layer
model.add(Lambda(lambda x: x ** 2))
```
@braingineer
braingineer / fixer.py
Last active May 27, 2016 03:35
valar morprocess
'''
super ugly. but works.
'''
import subprocess
import time
while True:
ps = subprocess.Popen(['qstat'], stdout=subprocess.PIPE).communicate()[0]
jid = int(ps.split("\n")[2].split(" ")[0])
@braingineer
braingineer / july_10_example.ipynb
Last active July 10, 2016 14:26 — forked from anonymous/july_10_example.ipynb
getting values from expressions in keras
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@braingineer
braingineer / pokemon go analysis.ipynb
Last active February 6, 2018 10:42 — forked from anonymous/pokemon go analysis.ipynb
pokemon go data analysis
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@braingineer
braingineer / murderbot.py
Last active August 15, 2016 01:10
procrastinating
def get_updates(model, loss):
updates = []
grad = SomeLibrary.grad(model.params, loss)
for param, g in zip(model.params, grad):
updates.append((params, param + model.lr * g))
return updates
def murderbot():
model = make_model()
while True:
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.
@braingineer
braingineer / latin_squares_experimental_design.ipynb
Created January 12, 2017 18:14 — forked from anonymous/latin_squares_experimental_design.ipynb
Latin Squares Experimental Design Generator
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.