This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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 | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |