Skip to content

Instantly share code, notes, and snippets.

View rohit-gupta's full-sized avatar

Rohit Gupta rohit-gupta

View GitHub Profile
@rohit-gupta
rohit-gupta / breitbart_comment_gen.py
Last active September 19, 2017 10:29
Training Language Model on Breitbart Comments
from keras.utils import Sequence
class BreitbartCommentsSequence(Sequence):
def __init__(self, comments, vocab_size, previous_words, batch_size):
all_comments_text = ' '.join(comments)
all_words = all_comments_text.split(" ")
vocabulary = collections.Counter(all_words)
self.vocabulary = [word for word, count in vocabulary.most_common(vocab_size)]
self.previous_words = previous_words
self.batch_size = batch_size
@rohit-gupta
rohit-gupta / install-quantum.sh
Created October 2, 2017 07:00
Install the blazing fast Firefox Quantum on Ubuntu/Linux Mint while keeping your old firefox install around as firefox-old
wget download-installer.cdn.mozilla.net/pub/firefox/releases/57.0b4/linux-x86_64/en-US/firefox-57.0b4.tar.bz2
wget http://download-installer.cdn.mozilla.net/pub/firefox/releases/57.0b4/SHA256SUMS
diff <(sha256sum firefox-57.0b4.tar.bz2 | awk 'BEGIN{FS=" "} {print $1}') <(grep "linux-x86_64/en-US/firefox-57.0b4.tar.bz2" SHA256SUMS | awk 'BEGIN{FS=" "} {print $1}')
tar xjf firefox-57.0b4.tar.bz2
sudo rm -r /opt/firefox
sudo mv firefox /opt/quantum
sudo mv /usr/bin/firefox /usr/bin/firefox-old
sudo ln -s /opt/quantum/firefox /usr/bin/firefox
@rohit-gupta
rohit-gupta / demo.py
Created October 17, 2017 09:12
Simple Function to remove English Languages stopwords without using NLTK
from stopwords import remove_stopwords
dummy_string = ("""Mr. and Mrs. Dursley, of number four, Privet Drive, were """
"""proud to say that they were perfectly normal, thank you """
"""very much. They were the last people you'd expect to be """
"""involved in anything strange or mysterious, because they """
"""just didn't hold with such nonsense.""")
# Simple Word tokenizer
dummy_list = dummy_string.replace(",", " ").replace(".", " ").split(" ")
@rohit-gupta
rohit-gupta / tikz_barchart.tex
Created December 4, 2017 07:58
Simple categorical barchart in LaTex
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
[ title = Number of videos in each category in MSR-VTT,
xbar,
@rohit-gupta
rohit-gupta / keras-beam-search.py
Created March 25, 2018 11:50
Generic beam search for Keras language models
def beam_search(captioning_model, prev_words_input, other_inputs, k):
top_k_predictions = [copy.deepcopy(prev_words_input) for _ in range(k)]
top_k_score = np.array([[0.0]*top_k_predictions[0].shape[0]]*k)
# First Iteration
predictions = captioning_model.predict(other_inputs + [prev_words_input])
for idx in range(prev_words_input.shape[0]):
for version in range(k):
top_k_predictions[version][idx][1] = np.argsort(predictions[idx])[-(version+1)]
top_k_score[version][idx] = np.sort(predictions[idx])[-(version+1)]
@rohit-gupta
rohit-gupta / action-recognition-papers.txt
Created August 31, 2018 10:46
Action Recognition Papers
ActivityNet 2018 Results: http://activity-net.org/challenges/2018/uploads/ActivityNet_Challenge_2018_Summary_and_Workshop_Papers.pdf
I3D: https://www.arxiv-vanity.com/papers/1705.07750/
3D CNNs: http://openaccess.thecvf.com/content_cvpr_2018/papers/Hara_Can_Spatiotemporal_3D_CVPR_2018_paper.pdf
AVA: http://openaccess.thecvf.com/content_cvpr_2018/papers/Gu_AVA_A_Video_CVPR_2018_paper.pdf
Kinetics: https://arxiv.org/pdf/1705.06950.pdf
@rohit-gupta
rohit-gupta / cool-papers.txt
Last active August 31, 2018 13:28
Random Cool Papers
How good is your GAN ? https://hal.inria.fr/hal-01850447/document
Low Shot visual recognition by hallucinating features https://arxiv.org/pdf/1606.02819.pdf
Google JFT-300M https://arxiv.org/pdf/1707.02968.pdf
Instagram Imagenet https://research.fb.com/wp-content/uploads/2018/05/exploring_the_limits_of_weakly_supervised_pretraining.pdf
Deep Layer Aggregation https://arxiv.org/pdf/1707.06484.pdf
CNNs fit random data https://arxiv.org/pdf/1611.03530.pdf
@rohit-gupta
rohit-gupta / get_lm_equation.R
Created September 19, 2018 13:51
Get equation text from a R lm (Linear Model) object for use as text in graph
# Get equation text from LM
# Format: y = a + b.x, R^2 = r^2
equation_text = function(x, round_dig = 2) {
lm_coef <- list(a = as.character(round(coef(x)[1], digits = round_dig)),
b = as.character(round(coef(x)[2], digits = round_dig)),
r2 = round(summary(x)$r.squared, digits = round_dig));
lm_eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(R)^2~"="~r2,lm_coef)
as.character(as.expression(lm_eq));
}
@rohit-gupta
rohit-gupta / ggrepel_scatter.R
Created September 19, 2018 13:54
Scatter plot with neat text lables using ggrepel
# Basic Name Plot
tax_plot <- ggplot(State_Infrastructure, aes(x=tax_burden, y=percent_bad_roads, label=State))
tax_state_names_plot <- tax_plot + geom_text_repel() + geom_point(color = 'red') + theme_classic(base_size = 16)
# OUTPUT
tax_state_names_plot + ggtitle("Road Conditions vs Tax Burden") +
scale_x_continuous(name = "State and Local Tax Burden") +
scale_y_continuous(name = "Percent of roads not in good condition")
@rohit-gupta
rohit-gupta / linear_regression_plot.R
Created September 19, 2018 13:55
Plotting the results of a simple linear regression in R
# Tax regression plot
# Linear Regression
tax_fit <- lm(percent_bad_roads ~ tax_burden, data = State_Infrastructure)
min_gap = 0.05
lab_coord_xmin = min(State_Infrastructure$tax_burden)
lab_coord_xmax = max(State_Infrastructure$tax_burden)
lab_coord_ymin = min(State_Infrastructure$percent_bad_roads) - min_gap
lab_coord_height = 0.1