Skip to content

Instantly share code, notes, and snippets.

View roddar92's full-sized avatar

Dashka Rodionova roddar92

View GitHub Profile
@tokestermw
tokestermw / birnnlm_pytorch.py
Last active May 30, 2020 08:29
Simple example of Bidirectional RNN Language Model in PyTorch. (blog post: https://medium.com/@plusepsilon/the-bidirectional-language-model-1f3961d1fb27)
import torch, torch.nn as nn
from torch.autograd import Variable
text = ['BOS', 'How', 'are', 'you', 'EOS']
seq_len = len(text)
batch_size = 1
embedding_size = 1
hidden_size = 1
output_size = 1
@codehacken
codehacken / hclustering.py
Created July 27, 2017 20:01
Agglomerative clustering using Scikit-Learn (with a custom distance metric)
"""
Hierarchial Clustering.
The goal of gist is to show to use scikit-learn to perform agglomerative clustering when:
1. There is a need for a custom distance metric (like levenshtein distance)
2. Use the distance in sklearn's API.
Adapted from: sklearn's FAQ.
http://scikit-learn.org/stable/faq.html
"""
@alexeygrigorev
alexeygrigorev / RuleBasedPosTagger.java
Created July 14, 2015 10:17
Simple rule-based POS tagger for Russian (StanfordNLP & java)
package mlp.rus;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;