I hereby claim:
- I am gavincangan on github.
- I am bgavin (https://keybase.io/bgavin) on keybase.
- I have a public key ASAzVotPWrTux92cdLLsndyYfpkLiCaj9vofPyQzC1yAFQo
To claim this, I am signing this object:
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 |
from tensorflow.python.client import device_lib | |
def get_available_gpus(): | |
local_device_protos = device_lib.list_local_devices() | |
return [x.name for x in local_device_protos if x.device_type == 'GPU'] | |
get_available_gpus() |
# variation to https://github.com/ryankiros/skip-thoughts/blob/master/decoding/search.py | |
def keras_rnn_predict(samples, empty=empty, rnn_model=model, maxlen=maxlen): | |
"""for every sample, calculate probability for every possible label | |
you need to supply your RNN model and maxlen - the length of sequences it can handle | |
""" | |
data = sequence.pad_sequences(samples, maxlen=maxlen, value=empty) | |
return rnn_model.predict(data, verbose=0) | |
def beamsearch(predict=keras_rnn_predict, |
import tensorflow as tf | |
def beam_decoder(decoder_inputs, initial_state, cell, loop_function, scope=None, | |
beam_size=7, done_token=0 | |
): | |
""" | |
Beam search decoder | |
Args: | |
decoder_inputs: A list of 2D Tensors [batch_size x input_size]. |
import time | |
import math | |
def find_fact(num, cur_quot=[]): | |
ix = 3 | |
if(num < 2): | |
return cur_quot | |
while(ix < math.sqrt(num)): | |
if(num % ix == 0): | |
cur_quot.append(ix) |
#!/bin/bash | |
cpp_file_to_build=$1 | |
output_file=$(pwd)/${cpp_file_to_build/\.cpp/\.o} | |
rename_output_file=$(pwd)/zz_${cpp_file_to_build/\.cpp/\.o}ld | |
mv $output_file $rename_output_file | |
g++ -std=gnu++11 -Wall $cpp_file_to_build -o $output_file; |
# Check for open ports in a range | |
for i in $(seq 20 99); do netcat -v -n -z -w 1 192.168.5.$i 22; done | |
# Windows - show WiFi password | |
netsh wlan show profile name=”<Profile-Name>” key=clear | |
# Windows - show all devices in network | |
arp -a | |
# Convert images or other files to pdf using ImageMagick |
I hereby claim:
To claim this, I am signing this object:
/* | |
* Source: https://stackoverflow.com/questions/8401777/simple-glob-in-c-on-unix-system | |
*/ | |
#include <glob.h> // glob(), globfree() | |
#include <string.h> // memset() | |
#include <vector> | |
#include <stdexcept> | |
#include <string> | |
#include <sstream> |
% https://stats.stackexchange.com/a/394487/204863 | |
clear; close all; | |
num_points = 100; | |
xrange = [-100, 100]; | |
x = xrange(1) + 2 * xrange(2) * rand(num_points, 1); | |
yrange = [0, 20]; | |
y = yrange(1) + 2 * yrange(2) * rand(num_points, 1); |