Skip to content

Instantly share code, notes, and snippets.

View evilying's full-sized avatar
🎯
Focusing

Jack evilying

🎯
Focusing
View GitHub Profile
@chao-ji
chao-ji / beamsearch_decoder.py
Last active March 4, 2024 07:09
Easy to understand implementation of beam search algorithm used in decoder of seq2seq models
"""NumPy implementation of Beam Search. Can be used for decoding in Seq2Seq
models or transformer.
See https://chao-ji.github.io/jekyll/update/2019/01/24/Beam_Search.html
for an in-depth disucssion.
"""
import numpy as np
NEG_INF = -1e9
@tdomhan
tdomhan / coef_weight_plot.py
Created September 8, 2013 18:16
plotting the largest weights of a L2 regularized classifier + their names
import matplotlib.pyplot as plt
import numpy as np
figsize(20,8)
#clf is a sklearn classifier e.g. clf = LogisticRegression()
#vecotorizer is a sklearn vectorizer, e.g. vectorizer = TfidfVectorizer()
#let's get the coefficients:
coef = clf.coef_.ravel()
important = np.argsort(np.abs(coef))[-100:]