Skip to content

Instantly share code, notes, and snippets.

View styx97's full-sized avatar
💭
Aspiring Computational Linguist

Rupak Sarkar styx97

💭
Aspiring Computational Linguist
View GitHub Profile
@HarshTrivedi
HarshTrivedi / pad_packed_demo.py
Last active July 5, 2024 22:47 — forked from Tushar-N/pad_packed_demo.py
Minimal tutorial on packing (pack_padded_sequence) and unpacking (pad_packed_sequence) sequences in pytorch.
import torch
from torch import LongTensor
from torch.nn import Embedding, LSTM
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
## We want to run LSTM on a batch of 3 character sequences ['long_str', 'tiny', 'medium']
#
# Step 1: Construct Vocabulary
# Step 2: Load indexed data (list of instances, where each instance is list of character indices)
@RustingSword
RustingSword / tsne_plot.py
Created April 23, 2018 06:09
Plot TSNE-ed embedding of word vectors generated by fasttext. Require https://github.com/DmitryUlyanov/Multicore-TSNE
#!/usr/bin/env python
#! coding: utf8
from __future__ import print_function
from bokeh.plotting import figure, show, output_file
from bokeh.models import ColumnDataSource, LabelSet, HoverTool
import argparse
import numpy as np
from numpy.linalg import norm
from MulticoreTSNE import MulticoreTSNE as TSNE