Skip to content

Instantly share code, notes, and snippets.

View lfloeer's full-sized avatar

Lars lfloeer

View GitHub Profile
@cbaziotis
cbaziotis / AttentionWithContext.py
Last active April 25, 2022 14:37
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':
@cbaziotis
cbaziotis / Attention.py
Last active October 22, 2024 08:31
Keras Layer that implements an Attention mechanism for temporal data. Supports Masking. Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
from keras import backend as K, initializers, regularizers, constraints
from keras.engine.topology import Layer
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
@parente
parente / README.md
Last active May 25, 2016 17:20
All-In-One Jupyter Notebook to Jupyter Dashboard Server
@dukenmarga
dukenmarga / matplotlib-cherrypy.py
Last active January 26, 2024 10:07
matplotlib on CherryPy
# Modified from https://gist.github.com/tkf/1299670 by @tkf
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
import cherrypy
from cStringIO import StringIO