Skip to content

Instantly share code, notes, and snippets.

View domluna's full-sized avatar
🐺
howling time

Dominique Luna domluna

🐺
howling time
View GitHub Profile
@domluna
domluna / out.jl
Created April 8, 2019 03:04
Formatted cppwrapper.jl using JLFmt
struct CPolygon
vertexlist::Ptr{Cint}
numberofvertices::Cint
end
struct CFacet{T}
polygonlist::Ptr{CPolygon}
numberofpolygons::Cint
@domluna
domluna / utils.jl
Created October 25, 2018 03:26
Formatted utils.jl
export @esc, isexpr, isline, rmlines, unblock, block, inexpr, namify, isdef,
longdef, shortdef, @expand, makeif, prettify, splitdef, splitarg
"""
assoc!(d, k, v)
is the same as `d[k] = v` but returns `d` rather than `v`.
"""
assoc!(d, k, v) = (d[k] = v; d)
@domluna
domluna / attention_transformer.md
Created September 25, 2018 00:57
Notes about attention and transformer

Transformer notes

  • current models have trouble learning dependencies over distance (i.e. between characters/words), # ops scale O(n) or O(log n).

  • transformer is O(1) in number of ops

  • encoder-decoder with residual conns. Encoder/decodes feed into themselves N times.

  • We also modify the self-attention sub-layer in the decoder stack to prevent positions from attending to subsequent positions. This masking, combined with fact that the output embeddings are offset by one position, **ensures that the predictions for position i can depend only on the known outputs at positions less than i **.

def subsequent_mask(size):
import tensorflow as tf
import numpy as np
x = tf.constant(np.random.randn(1, 4, 4, 2), dtype=tf.float32)
# TODO: Use `tf.layers.conv2d_transpose` to return a tensor
# with the shape (1, 8, 8, 5)
conv = 0
with tf.Session() as sess:
def iou(img, y, c):
intersection = 0.
union = 0.
img = img.reshape(-1)
y = y.reshape(-1)
for i in range(len(img)):
intersection += img[i] == c and y[i] == c
union += img[i] == c or y[i] == c
return intersection / union
"""
Load SavedModel
Output graphdef and checkpoint files
"""
import tensorflow as tf
import argparse
import sys
@domluna
domluna / steps.sh
Created May 27, 2017 01:39 — forked from albertstartup/steps.sh
aws gpu, ubuntu 16.04, nvidia driver 367, cuda 8,
# Required downloads:
# NVIDIA-Linux-x86_64-367.27.run
# cuda_8.0.27_linux.run
# cudnn-8.0-linux-x64-v5.0-ga.tgz
sudo apt-get install build-essential
sudo apt-get install linux-image-extra-`uname -r`
sudo ./NVIDIA-Linux-x86_64-367.27.run
./cuda_8.0.27_linux.run --extract=`pwd`/extracts
sudo ./extracts/cuda-linux64-rel-8.0.27-20733550.run
import tensorflow as tf
import numpy as np
w = np.arange(1, 10, dtype=np.float32).reshape((3,3,1,1))
f = tf.Variable(tf.constant(w))
input = tf.placeholder(tf.float32, (None, 28, 28, 1))
conv = tf.nn.conv2d(input, f, [1,2,2,1], 'SAME')
s = tf.Session()
x = np.zeros((28, 28), dtype=np.float32)
import tensorflow as tf
import numpy as np
w = np.arange(1, 10, dtype=np.float32).reshape((3,3,1,1))
f = tf.Variable(tf.constant(w))
input = tf.placeholder(tf.float32, (None, 28, 28, 1))
conv = tf.nn.conv2d(input, f, [1,2,2,1], 'VALID')
s = tf.Session()
x = np.zeros((28, 28), dtype=np.float32)
@domluna
domluna / env.yml
Last active November 10, 2016 01:42
CarND Term 1 environment sample
name: CarND-Term1
channels:
- https://conda.anaconda.org/menpo
dependencies:
- python==3.5.2
- numpy
- matplotlib
- tensorflow
- jupyter
- opencv3