Skip to content

Instantly share code, notes, and snippets.

View erickrf's full-sized avatar

Erick Fonseca erickrf

View GitHub Profile
@bwhite
bwhite / rank_metrics.py
Created September 15, 2012 03:23
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@wangruohui
wangruohui / Install NVIDIA Driver and CUDA.md
Last active June 29, 2024 09:06
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@mbollmann
mbollmann / hidden_state_lstm.py
Created August 17, 2016 10:02
Keras LSTM that inputs/outputs its internal states, e.g. for hidden state transfer
from keras import backend as K
from keras.layers.recurrent import LSTM
class HiddenStateLSTM(LSTM):
"""LSTM with input/output capabilities for its hidden state.
This layer behaves just like an LSTM, except that it accepts further inputs
to be used as its initial states, and returns additional outputs,
representing the layer's final states.
@mtreviso
mtreviso / select_word_pieces.py
Last active November 4, 2019 17:33
Method to select word pieces from BERT (first, mean, sum, max)
@staticmethod
def select_word_pieces(features, bounds, method='first'):
"""
Args:
features (torch.Tensor): output of BERT. Shape of (bs, ts, h_dim)
bounds (torch.LongTensor): the indexes where the word pieces start.
Shape of (bs, ts)
e.g. Welcome to the jungle -> Wel_ _come _to _the _jungle
bounds[0] = [0, 2, 3, 4]
indexes for padding positions are expected to be equal to -1