Skip to content

Instantly share code, notes, and snippets.

@j-greer
j-greer / montecarlo.R
Created September 30, 2015 15:33
Simple MonteCarlo simulation
####### 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
@j-greer
j-greer / AttentionWithContext.py
Created August 7, 2018 17:40 — 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"
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':