Skip to content

Instantly share code, notes, and snippets.

View EderSantana's full-sized avatar
🎯
Focusing

Eder Santana EderSantana

🎯
Focusing
View GitHub Profile
@udibr
udibr / gruln.py
Last active November 7, 2020 02:34
Keras GRU with Layer Normalization
import numpy as np
from keras.layers import GRU, initializations, K
from collections import OrderedDict
class GRULN(GRU):
'''Gated Recurrent Unit with Layer Normalization
Current impelemtation only works with consume_less = 'gpu' which is already
set.
# Arguments
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
# Define custom py_func which takes also a grad op as argument:
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
# Need to generate a unique name to avoid duplicates:
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))
@sklam
sklam / glinterop.py
Created August 16, 2016 18:03
Numba, PyCUDA, OpenGL interop. Adapted from https://wiki.tiker.net/PyCuda/Examples/GlInterop
# GL interoperability example, by Peter Berrington.
# Draws a rotating teapot, using cuda to invert the RGB value
# each frame
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL.ARB.vertex_buffer_object import *
from OpenGL.GL.ARB.pixel_buffer_object import *
@sklam
sklam / cuda_extern.py
Created September 19, 2016 14:14
Numba using NVCC device function
"""
Demonstrating CUDA JIT integration
"""
from __future__ import print_function
from numba import cuda
import numpy
import os
# Declare function to link to
bar = cuda.declare_device('bar', 'int32(voidptr, int32)')
'''
A logistic regression example using the meta-graph checkpointing
features of Tensorflow.
Author: João Felipe Santos, based on code by Aymeric Damien
(https://github.com/aymericdamien/TensorFlow-Examples/)
'''
from __future__ import print_function
@ndronen
ndronen / model.py
Last active April 28, 2018 19:50
Semantic segmentation with ENet in PyTorch
#!/usr/bin/env python
"""
A quick, partial implementation of ENet (https://arxiv.org/abs/1606.02147) using PyTorch.
The original Torch ENet implementation can process a 480x360 image in ~12 ms (on a P2 AWS
instance). TensorFlow takes ~35 ms. The PyTorch implementation takes ~25 ms, an improvement
over TensorFlow, but worse than the original Torch.
"""
from __future__ import absolute_import
@jganzabal
jganzabal / Nvidia Titan XP + MacBook Pro + Akitio Node + Tensorflow + Keras.md
Last active November 2, 2022 11:43
How to setup Nvidia Titan XP for deep learning on a MacBook Pro with Akitio Node + Tensorflow + Keras