Skip to content

Instantly share code, notes, and snippets.

View matpalm's full-sized avatar
🎯
Focusing

mat kelcey matpalm

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python3
from tensorflow.keras import models
from tensorflow.keras import layers
inp = layers.Input(shape=(1,))
out = layers.ReLU()(inp)
model = models.Model(inp, out)
model.compile(loss='mean_squared_error', optimizer='sgd')
#!/usr/bin/env python3
from tensorflow.keras import models
from tensorflow.keras import layers
inp = layers.Input(shape=(1,))
out = layers.Activation('relu')(inp)
model = models.Model(inp, out)
#!/usr/bin/env python3
from tensorflow.keras import models
from tensorflow.keras import layers
inp = layers.Input(shape=(1,))
out = layers.ReLU()(inp)
model = models.Model(inp, out)
{
"encoder_enabled": {"x": 1, "y": 1, "z": 1 },
"encoder_invert": {"x": 0, "y": 0, "z": 0 },
"encoder_missed_steps_decay": {"x": 5, "y": 5, "z": 5 },
"encoder_missed_steps_max": {"x": 5, "y": 5, "z": 5 },
"encoder_scaling": {"x": 5556, "y": 5556, "z": 5556 },
"encoder_type": {"x": 0, "y": 0, "z": 0 },
"encoder_use_for_pos": {"x": 0, "y": 0, "z": 0 },
"movement_axis_nr_steps": {"x": 0, "y": 0, "z": 0 },
"movement_enable_endpoints": {"x": 0, "y": 0, "z": 0 },
#!/usr/bin/env python3
from PIL import Image
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
# smooth values from point a to point b.
STEPS = 100
pt_a = np.random.normal(size=(512))
@matpalm
matpalm / BUGS.PAS
Last active November 2, 2016 03:29
{ This is an implementation of Scientific American "bugs" I did back in 1996 }
Program bugs; { fucking evil bugs, no less}
uses graph,crt;
const max_num=870;
sizex=160;
sizey=160;
var bnum,fnum,lastx,lasty:integer;
sx,sy :real;
b:array[1..max_num,1..7] of integer; {age,life,g1,g2,dir,xco,yxo}
#!/usr/bin/env python
# gpu_stat.py [DELAY [COUNT]]
# dump gpu stats as a line of json
# {"time": 1474168378.146957, "pci_tx": 146000, "pci_rx": 1508000,
# "gpu_util": 42, "mem_util": 24, "mem_used": 11710,
# "temp": 76, "fan_speed": 44, "power": 65 }
#!/usr/bin/env python
import sys
import numpy as np
print np.percentile(map(float, sys.stdin.readlines()),
np.linspace(0, 100, 11))
#!/usr/bin/env python
import theano
import theano.tensor as T
import numpy as np
NUM_TOKENS = 5 # number of tokens in sequence being attended to
D = 3 # generate embedding dim
np.random.seed(123)
# params of dummy RNN to gen data
@matpalm
matpalm / theano_word_embeddings.py
Created May 6, 2015 02:12
trivial word embeddings eg
#!/usr/bin/env python
# see http://matpalm.com/blog/2015/03/28/theano_word_embeddings/
import theano
import theano.tensor as T
import numpy as np
import random
E = np.asarray(np.random.randn(6, 2), dtype='float32')
t_E = theano.shared(E)
t_idxs = T.ivector()