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)
{
"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()
@matpalm
matpalm / gist:a81ee7f848c3f7db2ad8
Created March 31, 2015 02:43
numpy.__config__.show()
>>> numpy.__config__.show()
atlas_threads_info:
libraries = ['lapack', 'ptf77blas', 'ptcblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base/atlas', '/usr/lib/atlas-base']
define_macros = [('ATLAS_INFO', '"\\"3.8.4\\""')]
language = f77
include_dirs = ['/usr/include/atlas']
blas_opt_info:
libraries = ['ptf77blas', 'ptcblas', 'atlas']
library_dirs = ['/usr/lib/atlas-base']
mat@mat-desktop:~/dev/GTX970test$ make run
./test_bandwidth1.out
The bandwidth should stay be about the same each time:
Data size: 0.125000 GB; Bandwidth: 101725.257812 GB/s
Data size: 0.375000 GB; Bandwidth: 930059.500000 GB/s
Data size: 0.625000 GB; Bandwidth: 1514050.500000 GB/s
Data size: 0.875000 GB; Bandwidth: 2119670.750000 GB/s
Data size: 1.125000 GB; Bandwidth: 3662109.250000 GB/s
Data size: 1.375000 GB; Bandwidth: 4475911.500000 GB/s
Data size: 1.625000 GB; Bandwidth: 3998523.500000 GB/s