Skip to content

Instantly share code, notes, and snippets.

@nigeljyng
nigeljyng / TemporalMaxPooling.py
Last active Feb 21, 2020
Temporal max pooling as implemented in https://arxiv.org/abs/1511.04108
View TemporalMaxPooling.py
from keras import backend as K
from keras.engine import InputSpec
from keras.engine.topology import Layer
import numpy as np
class TemporalMaxPooling(Layer):
"""
This pooling layer accepts the temporal sequence output by a recurrent layer
and performs temporal pooling, looking at only the non-masked portion of the sequence.
@nigeljyng
nigeljyng / AttentionWithContext.py
Last active Feb 10, 2021 — forked from cbaziotis/AttentionWithContext.py
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"
View AttentionWithContext.py
class AttentionWithContext(Layer):
"""
Attention operation, 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"
by using a context vector to assist the attention
# Input shape
3D tensor with shape: `(samples, steps, features)`.
# Output shape
@nigeljyng
nigeljyng / curl_ssl.md
Last active Jun 6, 2016
How to fix cURL - https protocol not supported Problem on OSX
View curl_ssl.md
@nigeljyng
nigeljyng / multi-git.md
Created Jun 4, 2016 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer.
View multi-git.md

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.

@nigeljyng
nigeljyng / pathogen.md
Last active Jul 25, 2016 — forked from romainl/gist:9970697
How to use Tim Pope's Pathogen.
View pathogen.md

How to use Tim Pope's Pathogen.

I'll assume you are on Linux or Mac OSX. For Windows, replace ~/.vim/ with $HOME\vimfiles\ and forward slashes with backward slashes.

The idea.

Vim plugins are collections of specialized scripts that you are supposed to put in "standard" locations under your ~/.vim/ directory. Syntax scripts go into ~/.vim/syntax/, plugin scripts go into ~/.vim/plugin, documentation goes into ~/.vim/doc/ and so on. That design can lead to a messy config where it quickly becomes hard to manage your plugins.

This is not the place to explain the technicalities behind Pathogen but the basic concept is quite straightforward: each plugin lives in its own directory under ~/.vim/bundle/, where each directory simulates the standard structure of your ~/.vim/ directory.