Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Greer j-greer

View GitHub Profile
@j-greer
j-greer / AttentionWithContext.py
Created Aug 7, 2018 — 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
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':
@j-greer
j-greer / montecarlo.R
Created Sep 30, 2015
Simple MonteCarlo simulation
View montecarlo.R
####### load required packages and ste seed ########
library(mc2d) #for PERT distribution
library(ggplot2) #for plotting
set.seed(1501)
DDoS <- 10 #Number of DDoS attacks per year
software_cost <- 100000 #Cost of new technology
DDoS_new <- runif(n=1000,min=3,max=6) #Num of attacks after investment
downtime_min <- 2