Skip to content

Instantly share code, notes, and snippets.

View bendaizer's full-sized avatar

Amine Benhenni bendaizer

View GitHub Profile
@udibr
udibr / beamsearch.py
Last active October 4, 2021 11:50
beam search for Keras RNN
# 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,
@jcbozonier
jcbozonier / gist:7da348d57a1dcb8acbfe
Last active August 29, 2015 14:15 — forked from anonymous/gist:f77b3da951681d3d2528
TCP server that streams currently tweeting twitter handles of those around NYC for use via Apache Spark. Code HEAVILY borrowed from http://kmkeen.com/socketserver/ Made to work with Spark by Justin Bozonier
import SocketServer, subprocess, sys
from threading import Thread
from TwitterAPI import TwitterAPI
import json, unidecode
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
HOST = 'localhost'
PORT = 9999
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing