├── .gitignore ├── LICENSE ├── README.md ├── char-rnn-classification ├── .gitignore ├── char-rnn-classification.ipynb ├── data.py ├── model.py ├── predict.py ├── server.py └── train.py ├── char-rnn-generation ├── README.md ├── char-rnn-generation.ipynb ├── generate.py ├── helpers.py ├── model.py └── train.py ├── conditional-char-rnn ├── conditional-char-rnn.ipynb ├── data.py ├── generate.py ├── model.py └── train.py ├── data └── names │ ├── Arabic.txt │ ├── Chinese.txt │ ├── Czech.txt │ ├── Dutch.txt │ ├── English.txt │ ├── French.txt │ ├── German.txt │ ├── Greek.txt │ ├── Irish.txt │ ├── Italian.txt │ ├── Japanese.txt │ ├── Korean.txt │ ├── Polish.txt │ ├── Portuguese.txt │ ├── Russian.txt │ ├── Scottish.txt │ ├── Spanish.txt │ └── Vietnamese.txt ├── glove-word-vectors └── glove-word-vectors.ipynb ├── reinforce-gridworld ├── helpers.py ├── reinforce-gridworld.ipynb └── reinforce-gridworld.py └── seq2seq-translation ├── images ├── attention-decoder-network.dot ├── attention-decoder-network.png ├── decoder-network.dot ├── decoder-network.png ├── decoder.png ├── decoder@2x.png ├── encoder-network.dot ├── encoder-network.png ├── seq2seq.png ├── seq2seq@2x.png ├── word-encoding.png └── word-encoding@2x.png ├── masked_cross_entropy.py ├── seq2seq-translation-batched.ipynb ├── seq2seq-translation-batched.py └── seq2seq-translation.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.pt 4 | .ipynb_checkpoints 5 | __pycache__ 6 | data/eng-*.txt 7 | *.csv 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Sean Robertson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **These tutorials have been merged into [the official PyTorch tutorials](https://github.com/pytorch/tutorials). Please go there for better maintained versions of these tutorials compatible with newer versions of PyTorch.** 2 | 3 | --- 4 | 5 | ![Practical Pytorch](https://i.imgur.com/eBRPvWB.png) 6 | 7 | Learn PyTorch with project-based tutorials. These tutorials demonstrate modern techniques with readable code and use regular data from the internet. 8 | 9 | ## Tutorials 10 | 11 | #### Series 1: RNNs for NLP 12 | 13 | Applying recurrent neural networks to natural language tasks, from classification to generation. 14 | 15 | * [Classifying Names with a Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/char-rnn-classification/char-rnn-classification.ipynb) 16 | * [Generating Shakespeare with a Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb) 17 | * [Generating Names with a Conditional Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/conditional-char-rnn/conditional-char-rnn.ipynb) 18 | * [Translation with a Sequence to Sequence Network and Attention](https://github.com/spro/practical-pytorch/blob/master/seq2seq-translation/seq2seq-translation.ipynb) 19 | * [Exploring Word Vectors with GloVe](https://github.com/spro/practical-pytorch/blob/master/glove-word-vectors/glove-word-vectors.ipynb) 20 | * *WIP* Sentiment Analysis with a Word-Level RNN and GloVe Embeddings 21 | 22 | #### Series 2: RNNs for timeseries data 23 | 24 | * *WIP* Predicting discrete events with an RNN 25 | 26 | ## Get Started 27 | 28 | The quickest way to run these on a fresh Linux or Mac machine is to install [Anaconda](https://www.continuum.io/anaconda-overview): 29 | ``` 30 | curl -LO https://repo.continuum.io/archive/Anaconda3-4.3.0-Linux-x86_64.sh 31 | bash Anaconda3-4.3.0-Linux-x86_64.sh 32 | ``` 33 | 34 | Then install PyTorch: 35 | 36 | ``` 37 | conda install pytorch -c soumith 38 | ``` 39 | 40 | Then clone this repo and start Jupyter Notebook: 41 | 42 | ``` 43 | git clone http://github.com/spro/practical-pytorch 44 | cd practical-pytorch 45 | jupyter notebook 46 | ``` 47 | 48 | ## Recommended Reading 49 | 50 | ### PyTorch basics 51 | 52 | * http://pytorch.org/ For installation instructions 53 | * [Offical PyTorch tutorials](http://pytorch.org/tutorials/) for more tutorials (some of these tutorials are included there) 54 | * [Deep Learning with PyTorch: A 60-minute Blitz](http://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html) to get started with PyTorch in general 55 | * [Introduction to PyTorch for former Torchies](https://github.com/pytorch/tutorials/blob/master/Introduction%20to%20PyTorch%20for%20former%20Torchies.ipynb) if you are a former Lua Torch user 56 | * [jcjohnson's PyTorch examples](https://github.com/jcjohnson/pytorch-examples) for a more in depth overview (including custom modules and autograd functions) 57 | 58 | ### Recurrent Neural Networks 59 | 60 | * [The Unreasonable Effectiveness of Recurrent Neural Networks](http://karpathy.github.io/2015/05/21/rnn-effectiveness/) shows a bunch of real life examples 61 | * [Deep Learning, NLP, and Representations](http://colah.github.io/posts/2014-07-NLP-RNNs-Representations/) for an overview on word embeddings and RNNs for NLP 62 | * [Understanding LSTM Networks](http://colah.github.io/posts/2015-08-Understanding-LSTMs/) is about LSTMs work specifically, but also informative about RNNs in general 63 | 64 | ### Machine translation 65 | 66 | * [Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation](http://arxiv.org/abs/1406.1078) 67 | * [Sequence to Sequence Learning with Neural Networks](http://arxiv.org/abs/1409.3215) 68 | 69 | ### Attention models 70 | 71 | * [Neural Machine Translation by Jointly Learning to Align and Translate](https://arxiv.org/abs/1409.0473) 72 | * [Effective Approaches to Attention-based Neural Machine Translation](https://arxiv.org/abs/1508.04025) 73 | 74 | ### Other RNN uses 75 | 76 | * [A Neural Conversational Model](http://arxiv.org/abs/1506.05869) 77 | 78 | ### Other PyTorch tutorials 79 | 80 | * [Deep Learning For NLP In PyTorch](https://github.com/rguthrie3/DeepLearningForNLPInPytorch) 81 | 82 | ## Feedback 83 | 84 | If you have ideas or find mistakes [please leave a note](https://github.com/spro/practical-pytorch/issues/new). 85 | -------------------------------------------------------------------------------- /char-rnn-classification/.gitignore: -------------------------------------------------------------------------------- 1 | *.pt 2 | *.swp 3 | *.swo 4 | __pycache__ 5 | .ipynb_checkpoints 6 | -------------------------------------------------------------------------------- /char-rnn-classification/data.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import glob 3 | import unicodedata 4 | import string 5 | 6 | all_letters = string.ascii_letters + " .,;'-" 7 | n_letters = len(all_letters) 8 | 9 | def findFiles(path): return glob.glob(path) 10 | 11 | # Turn a Unicode string to plain ASCII, thanks to http://stackoverflow.com/a/518232/2809427 12 | def unicodeToAscii(s): 13 | return ''.join( 14 | c for c in unicodedata.normalize('NFD', s) 15 | if unicodedata.category(c) != 'Mn' 16 | and c in all_letters 17 | ) 18 | 19 | # Read a file and split into lines 20 | def readLines(filename): 21 | lines = open(filename).read().strip().split('\n') 22 | return [unicodeToAscii(line) for line in lines] 23 | 24 | # Build the category_lines dictionary, a list of lines per category 25 | category_lines = {} 26 | all_categories = [] 27 | for filename in findFiles('../data/names/*.txt'): 28 | category = filename.split('/')[-1].split('.')[0] 29 | all_categories.append(category) 30 | lines = readLines(filename) 31 | category_lines[category] = lines 32 | 33 | n_categories = len(all_categories) 34 | 35 | # Find letter index from all_letters, e.g. "a" = 0 36 | def letterToIndex(letter): 37 | return all_letters.find(letter) 38 | 39 | # Turn a line into a , 40 | # or an array of one-hot letter vectors 41 | def lineToTensor(line): 42 | tensor = torch.zeros(len(line), 1, n_letters) 43 | for li, letter in enumerate(line): 44 | tensor[li][0][letterToIndex(letter)] = 1 45 | return tensor 46 | 47 | -------------------------------------------------------------------------------- /char-rnn-classification/model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Variable 4 | 5 | class RNN(nn.Module): 6 | def __init__(self, input_size, hidden_size, output_size): 7 | super(RNN, self).__init__() 8 | 9 | self.hidden_size = hidden_size 10 | 11 | self.i2h = nn.Linear(input_size + hidden_size, hidden_size) 12 | self.i2o = nn.Linear(input_size + hidden_size, output_size) 13 | self.softmax = nn.LogSoftmax() 14 | 15 | def forward(self, input, hidden): 16 | combined = torch.cat((input, hidden), 1) 17 | hidden = self.i2h(combined) 18 | output = self.i2o(combined) 19 | output = self.softmax(output) 20 | return output, hidden 21 | 22 | def initHidden(self): 23 | return Variable(torch.zeros(1, self.hidden_size)) 24 | -------------------------------------------------------------------------------- /char-rnn-classification/predict.py: -------------------------------------------------------------------------------- 1 | from model import * 2 | from data import * 3 | import sys 4 | 5 | rnn = torch.load('char-rnn-classification.pt') 6 | 7 | # Just return an output given a line 8 | def evaluate(line_tensor): 9 | hidden = rnn.initHidden() 10 | 11 | for i in range(line_tensor.size()[0]): 12 | output, hidden = rnn(line_tensor[i], hidden) 13 | 14 | return output 15 | 16 | def predict(line, n_predictions=3): 17 | output = evaluate(Variable(lineToTensor(line))) 18 | 19 | # Get top N categories 20 | topv, topi = output.data.topk(n_predictions, 1, True) 21 | predictions = [] 22 | 23 | for i in range(n_predictions): 24 | value = topv[0][i] 25 | category_index = topi[0][i] 26 | print('(%.2f) %s' % (value, all_categories[category_index])) 27 | predictions.append([value, all_categories[category_index]]) 28 | 29 | return predictions 30 | 31 | if __name__ == '__main__': 32 | predict(sys.argv[1]) 33 | -------------------------------------------------------------------------------- /char-rnn-classification/server.py: -------------------------------------------------------------------------------- 1 | from bottle import route, run 2 | from predict import * 3 | 4 | @route('/') 5 | def index(input_line): 6 | return {'result': predict(input_line, 10)} 7 | 8 | run(host='localhost', port=5533) 9 | -------------------------------------------------------------------------------- /char-rnn-classification/train.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from data import * 3 | from model import * 4 | import random 5 | import time 6 | import math 7 | 8 | n_hidden = 128 9 | n_epochs = 100000 10 | print_every = 5000 11 | plot_every = 1000 12 | learning_rate = 0.005 # If you set this too high, it might explode. If too low, it might not learn 13 | 14 | def categoryFromOutput(output): 15 | top_n, top_i = output.data.topk(1) # Tensor out of Variable with .data 16 | category_i = top_i[0][0] 17 | return all_categories[category_i], category_i 18 | 19 | def randomChoice(l): 20 | return l[random.randint(0, len(l) - 1)] 21 | 22 | def randomTrainingPair(): 23 | category = randomChoice(all_categories) 24 | line = randomChoice(category_lines[category]) 25 | category_tensor = Variable(torch.LongTensor([all_categories.index(category)])) 26 | line_tensor = Variable(lineToTensor(line)) 27 | return category, line, category_tensor, line_tensor 28 | 29 | rnn = RNN(n_letters, n_hidden, n_categories) 30 | optimizer = torch.optim.SGD(rnn.parameters(), lr=learning_rate) 31 | criterion = nn.NLLLoss() 32 | 33 | def train(category_tensor, line_tensor): 34 | hidden = rnn.initHidden() 35 | optimizer.zero_grad() 36 | 37 | for i in range(line_tensor.size()[0]): 38 | output, hidden = rnn(line_tensor[i], hidden) 39 | 40 | loss = criterion(output, category_tensor) 41 | loss.backward() 42 | 43 | optimizer.step() 44 | 45 | return output, loss.data[0] 46 | 47 | # Keep track of losses for plotting 48 | current_loss = 0 49 | all_losses = [] 50 | 51 | def timeSince(since): 52 | now = time.time() 53 | s = now - since 54 | m = math.floor(s / 60) 55 | s -= m * 60 56 | return '%dm %ds' % (m, s) 57 | 58 | start = time.time() 59 | 60 | for epoch in range(1, n_epochs + 1): 61 | category, line, category_tensor, line_tensor = randomTrainingPair() 62 | output, loss = train(category_tensor, line_tensor) 63 | current_loss += loss 64 | 65 | # Print epoch number, loss, name and guess 66 | if epoch % print_every == 0: 67 | guess, guess_i = categoryFromOutput(output) 68 | correct = '✓' if guess == category else '✗ (%s)' % category 69 | print('%d %d%% (%s) %.4f %s / %s %s' % (epoch, epoch / n_epochs * 100, timeSince(start), loss, line, guess, correct)) 70 | 71 | # Add current loss avg to list of losses 72 | if epoch % plot_every == 0: 73 | all_losses.append(current_loss / plot_every) 74 | current_loss = 0 75 | 76 | torch.save(rnn, 'char-rnn-classification.pt') 77 | 78 | -------------------------------------------------------------------------------- /char-rnn-generation/README.md: -------------------------------------------------------------------------------- 1 | # Practical PyTorch: Generating Shakespeare with a Character-Level RNN 2 | 3 | ## Dataset 4 | 5 | Download [this Shakespeare dataset](https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt) (from [Andrej Karpathy's char-rnn](https://github.com/karpathy/char-rnn)) and save as `shakespeare.txt` 6 | 7 | ## Jupyter Notebook 8 | 9 | The [Jupyter Notebook version of the tutorial](https://github.com/spro/practical-pytorch/blob/master/char-rnn-generation/char-rnn-generation.ipynb) describes the model and steps in detail. 10 | 11 | ## Python scripts 12 | 13 | Run `train.py` with a filename to train and save the network: 14 | 15 | ``` 16 | > python train.py shakespeare.txt 17 | 18 | Training for 2000 epochs... 19 | (10 minutes later) 20 | Saved as shakespeare.pt 21 | ``` 22 | 23 | After training the model will be saved as `[filename].pt` — now run `generate.py` with that filename to generate some new text: 24 | 25 | ``` 26 | > python generate.py shakespeare.pt --prime_str "Where" 27 | 28 | Where, you, and if to our with his drid's 29 | Weasteria nobrand this by then. 30 | 31 | AUTENES: 32 | It his zersit at he 33 | ``` 34 | 35 | ### Training options 36 | 37 | ``` 38 | Usage: train.py [filename] [options] 39 | 40 | Options: 41 | --n_epochs Number of epochs to train 42 | --print_every Log learning rate at this interval 43 | --hidden_size Hidden size of GRU 44 | --n_layers Number of GRU layers 45 | --learning_rate Learning rate 46 | --chunk_len Length of chunks to train on at a time 47 | ``` 48 | 49 | ### Generation options 50 | ``` 51 | Usage: generate.py [filename] [options] 52 | 53 | Options: 54 | -p, --prime_str String to prime generation with 55 | -l, --predict_len Length of prediction 56 | -t, --temperature Temperature (higher is more chaotic) 57 | ``` 58 | 59 | -------------------------------------------------------------------------------- /char-rnn-generation/char-rnn-generation.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "![](https://i.imgur.com/eBRPvWB.png)\n", 8 | "\n", 9 | "# Practical PyTorch: Generating Shakespeare with a Character-Level RNN\n", 10 | "\n", 11 | "[In the RNN classification tutorial](https://github.com/spro/practical-pytorch/blob/master/char-rnn-classification/char-rnn-classification.ipynb) we used a RNN to classify text one character at a time. This time we'll generate text one character at a time.\n", 12 | "\n", 13 | "```\n", 14 | "> python generate.py -n 500\n", 15 | "\n", 16 | "PAOLTREDN:\n", 17 | "Let, yil exter shis owrach we so sain, fleas,\n", 18 | "Be wast the shall deas, puty sonse my sheete.\n", 19 | "\n", 20 | "BAUFIO:\n", 21 | "Sirh carrow out with the knonuot my comest sifard queences\n", 22 | "O all a man unterd.\n", 23 | "\n", 24 | "PROMENSJO:\n", 25 | "Ay, I to Heron, I sack, againous; bepear, Butch,\n", 26 | "An as shalp will of that seal think.\n", 27 | "\n", 28 | "NUKINUS:\n", 29 | "And house it to thee word off hee:\n", 30 | "And thou charrota the son hange of that shall denthand\n", 31 | "For the say hor you are of I folles muth me?\n", 32 | "```\n", 33 | "\n", 34 | "This one might make you question the series title — \"is that really practical?\" However, these sorts of generative models form the basis of machine translation, image captioning, question answering and more. See the [Sequence to Sequence Translation tutorial](https://github.com/spro/practical-pytorch/blob/master/seq2seq-translation/seq2seq-translation.ipynb) for more on that topic." 35 | ] 36 | }, 37 | { 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "# Recommended Reading\n", 42 | "\n", 43 | "I assume you have at least installed PyTorch, know Python, and understand Tensors:\n", 44 | "\n", 45 | "* http://pytorch.org/ For installation instructions\n", 46 | "* [Deep Learning with PyTorch: A 60-minute Blitz](https://github.com/pytorch/tutorials/blob/master/Deep%20Learning%20with%20PyTorch.ipynb) to get started with PyTorch in general\n", 47 | "* [jcjohnson's PyTorch examples](https://github.com/jcjohnson/pytorch-examples) for an in depth overview\n", 48 | "* [Introduction to PyTorch for former Torchies](https://github.com/pytorch/tutorials/blob/master/Introduction%20to%20PyTorch%20for%20former%20Torchies.ipynb) if you are former Lua Torch user\n", 49 | "\n", 50 | "It would also be useful to know about RNNs and how they work:\n", 51 | "\n", 52 | "* [The Unreasonable Effectiveness of Recurrent Neural Networks](http://karpathy.github.io/2015/05/21/rnn-effectiveness/) shows a bunch of real life examples\n", 53 | "* [Understanding LSTM Networks](http://colah.github.io/posts/2015-08-Understanding-LSTMs/) is about LSTMs specifically but also informative about RNNs in general\n", 54 | "\n", 55 | "Also see these related tutorials from the series:\n", 56 | "\n", 57 | "* [Classifying Names with a Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/char-rnn-classification/char-rnn-classification.ipynb) uses an RNN for classification\n", 58 | "* [Generating Names with a Conditional Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/conditional-char-rnn/conditional-char-rnn.ipynb) builds on this model to add a category as input" 59 | ] 60 | }, 61 | { 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "# Prepare data\n", 66 | "\n", 67 | "The file we are using is a plain text file. We turn any potential unicode characters into plain ASCII by using the `unidecode` package (which you can install via `pip` or `conda`)." 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": 1, 73 | "metadata": { 74 | "collapsed": false 75 | }, 76 | "outputs": [ 77 | { 78 | "name": "stdout", 79 | "output_type": "stream", 80 | "text": [ 81 | "file_len = 1115394\n" 82 | ] 83 | } 84 | ], 85 | "source": [ 86 | "import unidecode\n", 87 | "import string\n", 88 | "import random\n", 89 | "import re\n", 90 | "\n", 91 | "all_characters = string.printable\n", 92 | "n_characters = len(all_characters)\n", 93 | "\n", 94 | "file = unidecode.unidecode(open('../data/shakespeare.txt').read())\n", 95 | "file_len = len(file)\n", 96 | "print('file_len =', file_len)" 97 | ] 98 | }, 99 | { 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "To make inputs out of this big string of data, we will be splitting it into chunks." 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 2, 109 | "metadata": { 110 | "collapsed": false 111 | }, 112 | "outputs": [ 113 | { 114 | "name": "stdout", 115 | "output_type": "stream", 116 | "text": [ 117 | " will continue that I broach'd in jest.\n", 118 | "I can, Petruchio, help thee to a wife\n", 119 | "With wealth enough and young and beauteous,\n", 120 | "Brought up as best becomes a gentlewoman:\n", 121 | "Her only fault, and that is faults en\n" 122 | ] 123 | } 124 | ], 125 | "source": [ 126 | "chunk_len = 200\n", 127 | "\n", 128 | "def random_chunk():\n", 129 | " start_index = random.randint(0, file_len - chunk_len)\n", 130 | " end_index = start_index + chunk_len + 1\n", 131 | " return file[start_index:end_index]\n", 132 | "\n", 133 | "print(random_chunk())" 134 | ] 135 | }, 136 | { 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "# Build the Model\n", 141 | "\n", 142 | "This model will take as input the character for step $t_{-1}$ and is expected to output the next character $t$. There are three layers - one linear layer that encodes the input character into an internal state, one GRU layer (which may itself have multiple layers) that operates on that internal state and a hidden state, and a decoder layer that outputs the probability distribution." 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 3, 148 | "metadata": { 149 | "collapsed": false 150 | }, 151 | "outputs": [], 152 | "source": [ 153 | "import torch\n", 154 | "import torch.nn as nn\n", 155 | "from torch.autograd import Variable\n", 156 | "\n", 157 | "class RNN(nn.Module):\n", 158 | " def __init__(self, input_size, hidden_size, output_size, n_layers=1):\n", 159 | " super(RNN, self).__init__()\n", 160 | " self.input_size = input_size\n", 161 | " self.hidden_size = hidden_size\n", 162 | " self.output_size = output_size\n", 163 | " self.n_layers = n_layers\n", 164 | " \n", 165 | " self.encoder = nn.Embedding(input_size, hidden_size)\n", 166 | " self.gru = nn.GRU(hidden_size, hidden_size, n_layers)\n", 167 | " self.decoder = nn.Linear(hidden_size, output_size)\n", 168 | " \n", 169 | " def forward(self, input, hidden):\n", 170 | " input = self.encoder(input.view(1, -1))\n", 171 | " output, hidden = self.gru(input.view(1, 1, -1), hidden)\n", 172 | " output = self.decoder(output.view(1, -1))\n", 173 | " return output, hidden\n", 174 | "\n", 175 | " def init_hidden(self):\n", 176 | " return Variable(torch.zeros(self.n_layers, 1, self.hidden_size))" 177 | ] 178 | }, 179 | { 180 | "cell_type": "markdown", 181 | "metadata": {}, 182 | "source": [ 183 | "# Inputs and Targets" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "Each chunk will be turned into a tensor, specifically a `LongTensor` (used for integer values), by looping through the characters of the string and looking up the index of each character in `all_characters`." 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "execution_count": 4, 196 | "metadata": { 197 | "collapsed": false 198 | }, 199 | "outputs": [ 200 | { 201 | "name": "stdout", 202 | "output_type": "stream", 203 | "text": [ 204 | "Variable containing:\n", 205 | " 10\n", 206 | " 11\n", 207 | " 12\n", 208 | " 39\n", 209 | " 40\n", 210 | " 41\n", 211 | "[torch.LongTensor of size 6]\n", 212 | "\n" 213 | ] 214 | } 215 | ], 216 | "source": [ 217 | "# Turn string into list of longs\n", 218 | "def char_tensor(string):\n", 219 | " tensor = torch.zeros(len(string)).long()\n", 220 | " for c in range(len(string)):\n", 221 | " tensor[c] = all_characters.index(string[c])\n", 222 | " return Variable(tensor)\n", 223 | "\n", 224 | "print(char_tensor('abcDEF'))" 225 | ] 226 | }, 227 | { 228 | "cell_type": "markdown", 229 | "metadata": {}, 230 | "source": [ 231 | "Finally we can assemble a pair of input and target tensors for training, from a random chunk. The input will be all characters *up to the last*, and the target will be all characters *from the first*. So if our chunk is \"abc\" the input will correspond to \"ab\" while the target is \"bc\"." 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": 5, 237 | "metadata": { 238 | "collapsed": true 239 | }, 240 | "outputs": [], 241 | "source": [ 242 | "def random_training_set(): \n", 243 | " chunk = random_chunk()\n", 244 | " inp = char_tensor(chunk[:-1])\n", 245 | " target = char_tensor(chunk[1:])\n", 246 | " return inp, target" 247 | ] 248 | }, 249 | { 250 | "cell_type": "markdown", 251 | "metadata": {}, 252 | "source": [ 253 | "# Evaluating\n", 254 | "\n", 255 | "To evaluate the network we will feed one character at a time, use the outputs of the network as a probability distribution for the next character, and repeat. To start generation we pass a priming string to start building up the hidden state, from which we then generate one character at a time." 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": 6, 261 | "metadata": { 262 | "collapsed": false 263 | }, 264 | "outputs": [], 265 | "source": [ 266 | "def evaluate(prime_str='A', predict_len=100, temperature=0.8):\n", 267 | " hidden = decoder.init_hidden()\n", 268 | " prime_input = char_tensor(prime_str)\n", 269 | " predicted = prime_str\n", 270 | "\n", 271 | " # Use priming string to \"build up\" hidden state\n", 272 | " for p in range(len(prime_str) - 1):\n", 273 | " _, hidden = decoder(prime_input[p], hidden)\n", 274 | " inp = prime_input[-1]\n", 275 | " \n", 276 | " for p in range(predict_len):\n", 277 | " output, hidden = decoder(inp, hidden)\n", 278 | " \n", 279 | " # Sample from the network as a multinomial distribution\n", 280 | " output_dist = output.data.view(-1).div(temperature).exp()\n", 281 | " top_i = torch.multinomial(output_dist, 1)[0]\n", 282 | " \n", 283 | " # Add predicted character to string and use as next input\n", 284 | " predicted_char = all_characters[top_i]\n", 285 | " predicted += predicted_char\n", 286 | " inp = char_tensor(predicted_char)\n", 287 | "\n", 288 | " return predicted" 289 | ] 290 | }, 291 | { 292 | "cell_type": "markdown", 293 | "metadata": {}, 294 | "source": [ 295 | "# Training" 296 | ] 297 | }, 298 | { 299 | "cell_type": "markdown", 300 | "metadata": {}, 301 | "source": [ 302 | "A helper to print the amount of time passed:" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": 7, 308 | "metadata": { 309 | "collapsed": true 310 | }, 311 | "outputs": [], 312 | "source": [ 313 | "import time, math\n", 314 | "\n", 315 | "def time_since(since):\n", 316 | " s = time.time() - since\n", 317 | " m = math.floor(s / 60)\n", 318 | " s -= m * 60\n", 319 | " return '%dm %ds' % (m, s)" 320 | ] 321 | }, 322 | { 323 | "cell_type": "markdown", 324 | "metadata": {}, 325 | "source": [ 326 | "The main training function" 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "execution_count": 8, 332 | "metadata": { 333 | "collapsed": true 334 | }, 335 | "outputs": [], 336 | "source": [ 337 | "def train(inp, target):\n", 338 | " hidden = decoder.init_hidden()\n", 339 | " decoder.zero_grad()\n", 340 | " loss = 0\n", 341 | "\n", 342 | " for c in range(chunk_len):\n", 343 | " output, hidden = decoder(inp[c], hidden)\n", 344 | " loss += criterion(output, target[c])\n", 345 | "\n", 346 | " loss.backward()\n", 347 | " decoder_optimizer.step()\n", 348 | "\n", 349 | " return loss.data[0] / chunk_len" 350 | ] 351 | }, 352 | { 353 | "cell_type": "markdown", 354 | "metadata": {}, 355 | "source": [ 356 | "Then we define the training parameters, instantiate the model, and start training:" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": 9, 362 | "metadata": { 363 | "collapsed": false, 364 | "scrolled": false 365 | }, 366 | "outputs": [ 367 | { 368 | "name": "stdout", 369 | "output_type": "stream", 370 | "text": [ 371 | "[0m 19s (100 5%) 2.1267]\n", 372 | "Wh! 'Lod at the to Cell I dy\n", 373 | "Whapesfe show dous that,\n", 374 | "But thes lo he ther, letrst surave and and cod a \n", 375 | "\n", 376 | "[0m 38s (200 10%) 1.9876]\n", 377 | "Whan the she ciching, doove whath that he gone prie hasigrow nice knotat by wiith haye! ha coll, and i \n", 378 | "\n", 379 | "[0m 59s (300 15%) 2.0772]\n", 380 | "Whurgre of nowif for of agand witeling in fromound be noyed th well and fort and withen a custrone fri \n", 381 | "\n", 382 | "[1m 19s (400 20%) 1.9062]\n", 383 | "Why sleemer chome, I\n", 384 | "tence lord thou let not mories, Wherly me cloonger on wit, me cre wort if thing i \n", 385 | "\n", 386 | "[1m 39s (500 25%) 1.9632]\n", 387 | "Whank of winded than inderreast, hids for hink marry, I son will now my be tor think that I be uncient \n", 388 | "\n", 389 | "[2m 0s (600 30%) 1.9364]\n", 390 | "What to youre\n", 391 | "Good the dorsentemat.\n", 392 | "What the not what a meifery part is be of look\n", 393 | "Whait of the hall w \n", 394 | "\n", 395 | "[2m 20s (700 35%) 1.8673]\n", 396 | "Whes Bester,\n", 397 | "Bars, and and most man\n", 398 | "ingeld my tiement make I lesiefoden as do you same to muse woke o' \n", 399 | "\n", 400 | "[2m 40s (800 40%) 2.1523]\n", 401 | "Whe my bone a me but mast at the face.\n", 402 | "Whe he frend him cope a be to with I comes or he God his for ma \n", 403 | "\n", 404 | "[3m 1s (900 45%) 1.8042]\n", 405 | "Whis our namure.\n", 406 | "\n", 407 | "TRANIO:\n", 408 | "May platis the lord,\n", 409 | "I wis he we but he hards paron's we for the surven neav \n", 410 | "\n", 411 | "[3m 21s (1000 50%) 1.9770]\n", 412 | "Whis, is at ell demes sy host is in\n", 413 | "The revention eart-aly, his the couth stare.\n", 414 | "The streath, the so h \n", 415 | "\n", 416 | "[3m 42s (1100 55%) 1.9771]\n", 417 | "Which the called these what mace all bries,\n", 418 | "Gow the from ceart repise--tring be of the\n", 419 | "Hee he that, of \n", 420 | "\n", 421 | "[4m 3s (1200 60%) 1.7054]\n", 422 | "What that hays how the frow he dresers gard.\n", 423 | "\n", 424 | "BAPTISTA:\n", 425 | "That was on a prain their with to goe, all me\n", 426 | " \n", 427 | "\n", 428 | "[4m 23s (1300 65%) 1.6584]\n", 429 | "Whe time, like\n", 430 | "Those paurstriet.\n", 431 | "\n", 432 | "SICINIUS:\n", 433 | "Glow a and elfers; rother's Rome servest enon't is may thu \n", 434 | "\n", 435 | "[4m 44s (1400 70%) 1.7370]\n", 436 | "When him these;\n", 437 | "There and of Have the in of the do best veath and hever the chaw, not pites with at my \n", 438 | "\n", 439 | "[5m 6s (1500 75%) 1.6769]\n", 440 | "Wher he have live the courtas,\n", 441 | "I here that whils him I shee my like deated,\n", 442 | "To countert a hardor of so \n", 443 | "\n", 444 | "[5m 26s (1600 80%) 1.7480]\n", 445 | "Wh for the grone them with are\n", 446 | "Belent dis are couch of my to tell ding.\n", 447 | "\n", 448 | "Sir:\n", 449 | "What the deatred thou as \n", 450 | "\n", 451 | "[5m 48s (1700 85%) 1.7725]\n", 452 | "Why.\n", 453 | "\n", 454 | "CUMETEL:\n", 455 | "I carcithy place, did the forling like grease in ratenforer;\n", 456 | "Which ot chatuse, be thy p \n", 457 | "\n", 458 | "[6m 8s (1800 90%) 1.6781]\n", 459 | "What feath wifiten,\n", 460 | "Thou kind Maner'd my king: I'll thou\n", 461 | "Reven's my streathence,\n", 462 | "By civery sow'd king' \n", 463 | "\n", 464 | "[6m 28s (1900 95%) 1.5265]\n", 465 | "What so srome the and any strand?\n", 466 | "\n", 467 | "BAPTISTA:\n", 468 | "Not bother hear are a common int.\n", 469 | "\n", 470 | "QUEEN MIRGANSIO:\n", 471 | "I say \n", 472 | "\n", 473 | "[6m 49s (2000 100%) 1.5479]\n", 474 | "Why, ruse the tort,\n", 475 | "And whese a to the vill bear not tell not the the borwading.\n", 476 | "\n", 477 | "JULIET:\n", 478 | "In be our no \n", 479 | "\n" 480 | ] 481 | } 482 | ], 483 | "source": [ 484 | "n_epochs = 2000\n", 485 | "print_every = 100\n", 486 | "plot_every = 10\n", 487 | "hidden_size = 100\n", 488 | "n_layers = 1\n", 489 | "lr = 0.005\n", 490 | "\n", 491 | "decoder = RNN(n_characters, hidden_size, n_characters, n_layers)\n", 492 | "decoder_optimizer = torch.optim.Adam(decoder.parameters(), lr=lr)\n", 493 | "criterion = nn.CrossEntropyLoss()\n", 494 | "\n", 495 | "start = time.time()\n", 496 | "all_losses = []\n", 497 | "loss_avg = 0\n", 498 | "\n", 499 | "for epoch in range(1, n_epochs + 1):\n", 500 | " loss = train(*random_training_set()) \n", 501 | " loss_avg += loss\n", 502 | "\n", 503 | " if epoch % print_every == 0:\n", 504 | " print('[%s (%d %d%%) %.4f]' % (time_since(start), epoch, epoch / n_epochs * 100, loss))\n", 505 | " print(evaluate('Wh', 100), '\\n')\n", 506 | "\n", 507 | " if epoch % plot_every == 0:\n", 508 | " all_losses.append(loss_avg / plot_every)\n", 509 | " loss_avg = 0" 510 | ] 511 | }, 512 | { 513 | "cell_type": "markdown", 514 | "metadata": {}, 515 | "source": [ 516 | "# Plotting the Training Losses\n", 517 | "\n", 518 | "Plotting the historical loss from all_losses shows the network learning:" 519 | ] 520 | }, 521 | { 522 | "cell_type": "code", 523 | "execution_count": 10, 524 | "metadata": { 525 | "collapsed": false 526 | }, 527 | "outputs": [ 528 | { 529 | "data": { 530 | "text/plain": [ 531 | "[]" 532 | ] 533 | }, 534 | "execution_count": 10, 535 | "metadata": {}, 536 | "output_type": "execute_result" 537 | }, 538 | { 539 | "data": { 540 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAg0AAAFkCAYAAACjCwibAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAIABJREFUeJzt3Xl8VNX5x/HvYd8XUVlEq4JawAVZBAQFQUDBam1FjRtg\nfwqIRdGq1brUDXfUqohb645Wq+KGgKggIqJBtFpQFEQQZVMCsggh5/fHk+tMhklyJ5lkbpLP+/Wa\n12Tu3OXM3MncZ855zjnOey8AAIDiVMt0AQAAQMVA0AAAAEIhaAAAAKEQNAAAgFAIGgAAQCgEDQAA\nIBSCBgAAEApBAwAACIWgAQAAhELQAAAAQilV0OCc+6tzLs85N76Y9fo457Kdc1udc18654aW5rgA\nAKD8lThocM51lXSupE+KWW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NCoZ7338GOefOefmSVom\n6WRJizJTKgCF8d7/O+7h5865/0r6WlIf2QB+iKYJktqr6PmbykyUahrWStohi4biNZf0Q/kXB6Xh\nvc+R9KVsyPEfZPkpnNuKKcz5+0FSLedcoyLWQYR575fKvoeDjHvOacQ45+6VNEhSH+99/PxN5fY/\nGpmgwXu/XVK2pH7BsvxqmH4qo4k3UHaccw1kXz4r87+MflDBc9tIlgnMuY24kOcvW1JuwjoHSNpL\n0vvlVliUmHOutaRmik0myDmNkPyA4QRJR3nvv41/rjz/R6PWPDFe0qPOuWzZ9NljJdWT9GgmC4Xi\nOeduk/SKrEliD0nXStou6Zn8Ve6SdKVz7ivZlOfXy3rGTC73wmInxU1Ep2LOn/d+g3PuEUnjnXM/\nSdoo6R+S3vPezyvXFwNJRZ/T/Ns1su52P+Svd4usdnCqxDmNEufcBFl32OMlbXLOBTUKOd77rfl/\nl8//aKa7jiTpSnJe/gveIot+umS6TNxCnbdJ+R/QLbJs3Kcl7ZOwzt9l3YI2y76Y2ma63Nx+PTe9\nZV2vdiTc/hn2/EmqLetLvjb/C+k5Sbtn+rVV1VtR51Q24/AbsoBhq6Qlku6XtBvnNHq3Qs7jDkln\nJaxX5v+jTFgFAABCiUxOAwAAiDaCBgAAEApBAwAACIWgAQAAhELQAAAAQiFoAAAAoRA0AACAUAga\nAABAKAQNAAAgFIIGAAAQCkEDAAAI5f8BEXt19l83XNQAAAAASUVORK5CYII=\n", 541 | "text/plain": [ 542 | "" 543 | ] 544 | }, 545 | "metadata": {}, 546 | "output_type": "display_data" 547 | } 548 | ], 549 | "source": [ 550 | "import matplotlib.pyplot as plt\n", 551 | "import matplotlib.ticker as ticker\n", 552 | "%matplotlib inline\n", 553 | "\n", 554 | "plt.figure()\n", 555 | "plt.plot(all_losses)" 556 | ] 557 | }, 558 | { 559 | "cell_type": "markdown", 560 | "metadata": {}, 561 | "source": [ 562 | "# Evaluating at different \"temperatures\"\n", 563 | "\n", 564 | "In the `evaluate` function above, every time a prediction is made the outputs are divided by the \"temperature\" argument passed. Using a higher number makes all actions more equally likely, and thus gives us \"more random\" outputs. Using a lower value (less than 1) makes high probabilities contribute more. As we turn the temperature towards zero we are choosing only the most likely outputs.\n", 565 | "\n", 566 | "We can see the effects of this by adjusting the `temperature` argument." 567 | ] 568 | }, 569 | { 570 | "cell_type": "code", 571 | "execution_count": 11, 572 | "metadata": { 573 | "collapsed": false 574 | }, 575 | "outputs": [ 576 | { 577 | "name": "stdout", 578 | "output_type": "stream", 579 | "text": [ 580 | "Thoo head strant me reporce\n", 581 | "O and hears of thou provand of treech.\n", 582 | "\n", 583 | "LUCI death in that to tellon is head thing come thou that to not him with your firsure but,\n", 584 | "They here thyse of yet in thou thy meat to\n" 585 | ] 586 | } 587 | ], 588 | "source": [ 589 | "print(evaluate('Th', 200, temperature=0.8))" 590 | ] 591 | }, 592 | { 593 | "cell_type": "markdown", 594 | "metadata": {}, 595 | "source": [ 596 | "Lower temperatures are less varied, choosing only the more probable outputs:" 597 | ] 598 | }, 599 | { 600 | "cell_type": "code", 601 | "execution_count": 12, 602 | "metadata": { 603 | "collapsed": false 604 | }, 605 | "outputs": [ 606 | { 607 | "name": "stdout", 608 | "output_type": "stream", 609 | "text": [ 610 | "This commanderence the forself to the the to the the the to the to the the formands\n", 611 | "What to the strange the boy the the have the the to the to to the formands\n", 612 | "That the the the the the the sorn the to th\n" 613 | ] 614 | } 615 | ], 616 | "source": [ 617 | "print(evaluate('Th', 200, temperature=0.2))" 618 | ] 619 | }, 620 | { 621 | "cell_type": "markdown", 622 | "metadata": {}, 623 | "source": [ 624 | "Higher temperatures more varied, choosing less probable outputs:" 625 | ] 626 | }, 627 | { 628 | "cell_type": "code", 629 | "execution_count": 13, 630 | "metadata": { 631 | "collapsed": false 632 | }, 633 | "outputs": [ 634 | { 635 | "name": "stdout", 636 | "output_type": "stream", 637 | "text": [ 638 | "That,\n", 639 | "henct wto Haste's, norsee'd stave brYiry's is dsem.\n", 640 | "Hell hurss Heamous halloR:\n", 641 | "Tht a readerty the!\n", 642 | "\n", 643 | "KuWhrate.\n", 644 | "\n", 645 | "VLOMAY, mere's no, toojecur' kong.\n", 646 | "\n", 647 | "DUKE VIx whJos ivistomzliben\n", 648 | "The vrieglad bloot, \n" 649 | ] 650 | } 651 | ], 652 | "source": [ 653 | "print(evaluate('Th', 200, temperature=1.4))" 654 | ] 655 | }, 656 | { 657 | "cell_type": "markdown", 658 | "metadata": { 659 | "collapsed": true 660 | }, 661 | "source": [ 662 | "# Exercises\n", 663 | "\n", 664 | "* Train with your own dataset, e.g.\n", 665 | " * Text from another author\n", 666 | " * Blog posts\n", 667 | " * Code\n", 668 | "* Increase number of layers and network size to get better results" 669 | ] 670 | }, 671 | { 672 | "cell_type": "markdown", 673 | "metadata": {}, 674 | "source": [ 675 | "**Next**: [Generating Names with a Conditional Character-Level RNN](https://github.com/spro/practical-pytorch/blob/master/conditional-char-rnn/conditional-char-rnn.ipynb)" 676 | ] 677 | } 678 | ], 679 | "metadata": { 680 | "anaconda-cloud": {}, 681 | "kernelspec": { 682 | "display_name": "Python [conda root]", 683 | "language": "python", 684 | "name": "conda-root-py" 685 | }, 686 | "language_info": { 687 | "codemirror_mode": { 688 | "name": "ipython", 689 | "version": 3 690 | }, 691 | "file_extension": ".py", 692 | "mimetype": "text/x-python", 693 | "name": "python", 694 | "nbconvert_exporter": "python", 695 | "pygments_lexer": "ipython3", 696 | "version": "3.5.2" 697 | } 698 | }, 699 | "nbformat": 4, 700 | "nbformat_minor": 1 701 | } 702 | -------------------------------------------------------------------------------- /char-rnn-generation/generate.py: -------------------------------------------------------------------------------- 1 | # https://github.com/spro/practical-pytorch 2 | 3 | import torch 4 | 5 | from helpers import * 6 | from model import * 7 | 8 | def generate(decoder, prime_str='A', predict_len=100, temperature=0.8): 9 | hidden = decoder.init_hidden() 10 | prime_input = char_tensor(prime_str) 11 | predicted = prime_str 12 | 13 | # Use priming string to "build up" hidden state 14 | for p in range(len(prime_str) - 1): 15 | _, hidden = decoder(prime_input[p], hidden) 16 | 17 | inp = prime_input[-1] 18 | 19 | for p in range(predict_len): 20 | output, hidden = decoder(inp, hidden) 21 | 22 | # Sample from the network as a multinomial distribution 23 | output_dist = output.data.view(-1).div(temperature).exp() 24 | top_i = torch.multinomial(output_dist, 1)[0] 25 | 26 | # Add predicted character to string and use as next input 27 | predicted_char = all_characters[top_i] 28 | predicted += predicted_char 29 | inp = char_tensor(predicted_char) 30 | 31 | return predicted 32 | 33 | if __name__ == '__main__': 34 | # Parse command line arguments 35 | import argparse 36 | argparser = argparse.ArgumentParser() 37 | argparser.add_argument('filename', type=str) 38 | argparser.add_argument('-p', '--prime_str', type=str, default='A') 39 | argparser.add_argument('-l', '--predict_len', type=int, default=100) 40 | argparser.add_argument('-t', '--temperature', type=float, default=0.8) 41 | args = argparser.parse_args() 42 | 43 | decoder = torch.load(args.filename) 44 | del args.filename 45 | print(generate(decoder, **vars(args))) 46 | 47 | -------------------------------------------------------------------------------- /char-rnn-generation/helpers.py: -------------------------------------------------------------------------------- 1 | # https://github.com/spro/practical-pytorch 2 | 3 | import unidecode 4 | import string 5 | import random 6 | import time 7 | import math 8 | import torch 9 | from torch.autograd import Variable 10 | 11 | # Reading and un-unicode-encoding data 12 | 13 | all_characters = string.printable 14 | n_characters = len(all_characters) 15 | 16 | def read_file(filename): 17 | file = unidecode.unidecode(open(filename).read()) 18 | return file, len(file) 19 | 20 | # Turning a string into a tensor 21 | 22 | def char_tensor(string): 23 | tensor = torch.zeros(len(string)).long() 24 | for c in range(len(string)): 25 | tensor[c] = all_characters.index(string[c]) 26 | return Variable(tensor) 27 | 28 | # Readable time elapsed 29 | 30 | def time_since(since): 31 | s = time.time() - since 32 | m = math.floor(s / 60) 33 | s -= m * 60 34 | return '%dm %ds' % (m, s) 35 | 36 | -------------------------------------------------------------------------------- /char-rnn-generation/model.py: -------------------------------------------------------------------------------- 1 | # https://github.com/spro/practical-pytorch 2 | 3 | import torch 4 | import torch.nn as nn 5 | from torch.autograd import Variable 6 | 7 | class RNN(nn.Module): 8 | def __init__(self, input_size, hidden_size, output_size, n_layers=1): 9 | super(RNN, self).__init__() 10 | self.input_size = input_size 11 | self.hidden_size = hidden_size 12 | self.output_size = output_size 13 | self.n_layers = n_layers 14 | 15 | self.encoder = nn.Embedding(input_size, hidden_size) 16 | self.gru = nn.GRU(hidden_size, hidden_size, n_layers) 17 | self.decoder = nn.Linear(hidden_size, output_size) 18 | 19 | def forward(self, input, hidden): 20 | input = self.encoder(input.view(1, -1)) 21 | output, hidden = self.gru(input.view(1, 1, -1), hidden) 22 | output = self.decoder(output.view(1, -1)) 23 | return output, hidden 24 | 25 | def init_hidden(self): 26 | return Variable(torch.zeros(self.n_layers, 1, self.hidden_size)) 27 | 28 | -------------------------------------------------------------------------------- /char-rnn-generation/train.py: -------------------------------------------------------------------------------- 1 | # https://github.com/spro/practical-pytorch 2 | 3 | import torch 4 | import torch.nn as nn 5 | from torch.autograd import Variable 6 | import argparse 7 | import os 8 | 9 | from helpers import * 10 | from model import * 11 | from generate import * 12 | 13 | # Parse command line arguments 14 | argparser = argparse.ArgumentParser() 15 | argparser.add_argument('filename', type=str) 16 | argparser.add_argument('--n_epochs', type=int, default=2000) 17 | argparser.add_argument('--print_every', type=int, default=100) 18 | argparser.add_argument('--hidden_size', type=int, default=50) 19 | argparser.add_argument('--n_layers', type=int, default=2) 20 | argparser.add_argument('--learning_rate', type=float, default=0.01) 21 | argparser.add_argument('--chunk_len', type=int, default=200) 22 | args = argparser.parse_args() 23 | 24 | file, file_len = read_file(args.filename) 25 | 26 | def random_training_set(chunk_len): 27 | start_index = random.randint(0, file_len - chunk_len) 28 | end_index = start_index + chunk_len + 1 29 | chunk = file[start_index:end_index] 30 | inp = char_tensor(chunk[:-1]) 31 | target = char_tensor(chunk[1:]) 32 | return inp, target 33 | 34 | decoder = RNN(n_characters, args.hidden_size, n_characters, args.n_layers) 35 | decoder_optimizer = torch.optim.Adam(decoder.parameters(), lr=args.learning_rate) 36 | criterion = nn.CrossEntropyLoss() 37 | 38 | start = time.time() 39 | all_losses = [] 40 | loss_avg = 0 41 | 42 | def train(inp, target): 43 | hidden = decoder.init_hidden() 44 | decoder.zero_grad() 45 | loss = 0 46 | 47 | for c in range(args.chunk_len): 48 | output, hidden = decoder(inp[c], hidden) 49 | loss += criterion(output, target[c]) 50 | 51 | loss.backward() 52 | decoder_optimizer.step() 53 | 54 | return loss.data[0] / args.chunk_len 55 | 56 | def save(): 57 | save_filename = os.path.splitext(os.path.basename(args.filename))[0] + '.pt' 58 | torch.save(decoder, save_filename) 59 | print('Saved as %s' % save_filename) 60 | 61 | try: 62 | print("Training for %d epochs..." % args.n_epochs) 63 | for epoch in range(1, args.n_epochs + 1): 64 | loss = train(*random_training_set(args.chunk_len)) 65 | loss_avg += loss 66 | 67 | if epoch % args.print_every == 0: 68 | print('[%s (%d %d%%) %.4f]' % (time_since(start), epoch, epoch / args.n_epochs * 100, loss)) 69 | print(generate(decoder, 'Wh', 100), '\n') 70 | 71 | print("Saving...") 72 | save() 73 | 74 | except KeyboardInterrupt: 75 | print("Saving before quit...") 76 | save() 77 | 78 | -------------------------------------------------------------------------------- /conditional-char-rnn/data.py: -------------------------------------------------------------------------------- 1 | # Practical PyTorch: Generating Names with a Conditional Character-Level RNN 2 | # https://github.com/spro/practical-pytorch 3 | 4 | import glob 5 | import unicodedata 6 | import string 7 | import random 8 | import time 9 | import math 10 | 11 | import torch 12 | from torch.autograd import Variable 13 | 14 | # Preparing the Data 15 | 16 | all_letters = string.ascii_letters + " .,;'-" 17 | n_letters = len(all_letters) + 1 # Plus EOS marker 18 | EOS = n_letters - 1 19 | 20 | def unicode_to_ascii(s): 21 | return ''.join( 22 | c for c in unicodedata.normalize('NFD', s) 23 | if unicodedata.category(c) != 'Mn' 24 | and c in all_letters 25 | ) 26 | 27 | def read_lines(filename): 28 | lines = open(filename).read().strip().split('\n') 29 | return [unicode_to_ascii(line) for line in lines] 30 | 31 | category_lines = {} 32 | all_categories = [] 33 | for filename in glob.glob('../data/names/*.txt'): 34 | category = filename.split('/')[-1].split('.')[0] 35 | all_categories.append(category) 36 | lines = read_lines(filename) 37 | category_lines[category] = lines 38 | 39 | n_categories = len(all_categories) 40 | 41 | # Preparing for Training 42 | 43 | def random_training_pair(): 44 | category = random.choice(all_categories) 45 | line = random.choice(category_lines[category]) 46 | return category, line 47 | 48 | def make_category_input(category): 49 | li = all_categories.index(category) 50 | tensor = torch.zeros(1, n_categories) 51 | tensor[0][li] = 1 52 | return Variable(tensor) 53 | 54 | def make_chars_input(chars): 55 | tensor = torch.zeros(len(chars), n_letters) 56 | for ci in range(len(chars)): 57 | char = chars[ci] 58 | tensor[ci][all_letters.find(char)] = 1 59 | tensor = tensor.view(-1, 1, n_letters) 60 | return Variable(tensor) 61 | 62 | def make_target(line): 63 | letter_indexes = [all_letters.find(line[li]) for li in range(1, len(line))] 64 | letter_indexes.append(n_letters - 1) # EOS 65 | tensor = torch.LongTensor(letter_indexes) 66 | return Variable(tensor) 67 | 68 | def random_training_set(): 69 | category, line = random_training_pair() 70 | category_input = make_category_input(category) 71 | line_input = make_chars_input(line) 72 | line_target = make_target(line) 73 | return category_input, line_input, line_target 74 | 75 | -------------------------------------------------------------------------------- /conditional-char-rnn/generate.py: -------------------------------------------------------------------------------- 1 | # Practical PyTorch: Generating Names with a Conditional Character-Level RNN 2 | # https://github.com/spro/practical-pytorch 3 | 4 | import sys 5 | 6 | if len(sys.argv) < 2: 7 | print("Usage: generate.py [language]") 8 | sys.exit() 9 | 10 | else: 11 | language = sys.argv[1] 12 | 13 | import torch 14 | import torch.nn as nn 15 | from torch.autograd import Variable 16 | 17 | from data import * 18 | from model import * 19 | 20 | rnn = torch.load('conditional-char-rnn.pt') 21 | 22 | # Generating from the Network 23 | 24 | max_length = 20 25 | 26 | def generate_one(category, start_char='A', temperature=0.5): 27 | category_input = make_category_input(category) 28 | chars_input = make_chars_input(start_char) 29 | hidden = rnn.init_hidden() 30 | 31 | output_str = start_char 32 | 33 | for i in range(max_length): 34 | output, hidden = rnn(category_input, chars_input[0], hidden) 35 | 36 | # Sample as a multinomial distribution 37 | output_dist = output.data.view(-1).div(temperature).exp() 38 | top_i = torch.multinomial(output_dist, 1)[0] 39 | 40 | # Stop at EOS, or add to output_str 41 | if top_i == EOS: 42 | break 43 | else: 44 | char = all_letters[top_i] 45 | output_str += char 46 | chars_input = make_chars_input(char) 47 | 48 | return output_str 49 | 50 | def generate(category, start_chars='ABC'): 51 | for start_char in start_chars: 52 | print(generate_one(category, start_char)) 53 | 54 | generate(language) 55 | -------------------------------------------------------------------------------- /conditional-char-rnn/model.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Variable 4 | 5 | # Creating the Network 6 | 7 | class RNN(nn.Module): 8 | def __init__(self, category_size, input_size, hidden_size, output_size): 9 | super(RNN, self).__init__() 10 | self.category_size = category_size 11 | self.input_size = input_size 12 | self.hidden_size = hidden_size 13 | self.output_size = output_size 14 | 15 | self.i2h = nn.Linear(category_size + input_size + hidden_size, hidden_size) 16 | self.i2o = nn.Linear(category_size + input_size + hidden_size, output_size) 17 | self.o2o = nn.Linear(hidden_size + output_size, output_size) 18 | self.softmax = nn.LogSoftmax() 19 | 20 | def forward(self, category, input, hidden): 21 | input_combined = torch.cat((category, input, hidden), 1) 22 | hidden = self.i2h(input_combined) 23 | output = self.i2o(input_combined) 24 | output_combined = torch.cat((hidden, output), 1) 25 | output = self.o2o(output_combined) 26 | return output, hidden 27 | 28 | def init_hidden(self): 29 | return Variable(torch.zeros(1, self.hidden_size)) 30 | 31 | 32 | -------------------------------------------------------------------------------- /conditional-char-rnn/train.py: -------------------------------------------------------------------------------- 1 | # Practical PyTorch: Generating Names with a Conditional Character-Level RNN 2 | # https://github.com/spro/practical-pytorch 3 | 4 | import glob 5 | import unicodedata 6 | import string 7 | import random 8 | import time 9 | import math 10 | 11 | import torch 12 | import torch.nn as nn 13 | 14 | from data import * 15 | from model import * 16 | 17 | # Training the Network 18 | 19 | def train(category_tensor, input_line_tensor, target_line_tensor): 20 | hidden = rnn.init_hidden() 21 | optimizer.zero_grad() 22 | loss = 0 23 | 24 | for i in range(input_line_tensor.size()[0]): 25 | output, hidden = rnn(category_tensor, input_line_tensor[i], hidden) 26 | loss += criterion(output, target_line_tensor[i]) 27 | 28 | loss.backward() 29 | optimizer.step() 30 | 31 | return output, loss.data[0] / input_line_tensor.size()[0] 32 | 33 | def time_since(t): 34 | now = time.time() 35 | s = now - t 36 | m = math.floor(s / 60) 37 | s -= m * 60 38 | return '%dm %ds' % (m, s) 39 | 40 | n_epochs = 100000 41 | print_every = 5000 42 | plot_every = 500 43 | all_losses = [] 44 | loss_avg = 0 # Zero every plot_every epochs to keep a running average 45 | hidden_size = 128 46 | learning_rate = 0.0005 47 | 48 | rnn = RNN(n_categories, n_letters, hidden_size, n_letters) 49 | optimizer = torch.optim.Adam(rnn.parameters(), lr=learning_rate) 50 | criterion = nn.CrossEntropyLoss() 51 | 52 | start = time.time() 53 | 54 | def save(): 55 | torch.save(rnn, 'conditional-char-rnn.pt') 56 | 57 | try: 58 | print("Training for %d epochs..." % n_epochs) 59 | for epoch in range(1, n_epochs + 1): 60 | output, loss = train(*random_training_set()) 61 | loss_avg += loss 62 | 63 | if epoch % print_every == 0: 64 | print('%s (%d %d%%) %.4f' % (time_since(start), epoch, epoch / n_epochs * 100, loss)) 65 | 66 | if epoch % plot_every == 0: 67 | all_losses.append(loss_avg / plot_every) 68 | loss_avg = 0 69 | 70 | except KeyboardInterrupt: 71 | print("Saving before quit...") 72 | save() 73 | 74 | -------------------------------------------------------------------------------- /data/names/Arabic.txt: -------------------------------------------------------------------------------- 1 | Khoury 2 | Nahas 3 | Daher 4 | Gerges 5 | Nazari 6 | Maalouf 7 | Gerges 8 | Naifeh 9 | Guirguis 10 | Baba 11 | Sabbagh 12 | Attia 13 | Tahan 14 | Haddad 15 | Aswad 16 | Najjar 17 | Dagher 18 | Maloof 19 | Isa 20 | Asghar 21 | Nader 22 | Gaber 23 | Abboud 24 | Maalouf 25 | Zogby 26 | Srour 27 | Bahar 28 | Mustafa 29 | Hanania 30 | Daher 31 | Tuma 32 | Nahas 33 | Saliba 34 | Shamoon 35 | Handal 36 | Baba 37 | Amari 38 | Bahar 39 | Atiyeh 40 | Said 41 | Khouri 42 | Tahan 43 | Baba 44 | Mustafa 45 | Guirguis 46 | Sleiman 47 | Seif 48 | Dagher 49 | Bahar 50 | Gaber 51 | Harb 52 | Seif 53 | Asker 54 | Nader 55 | Antar 56 | Awad 57 | Srour 58 | Shadid 59 | Hajjar 60 | Hanania 61 | Kalb 62 | Shadid 63 | Bazzi 64 | Mustafa 65 | Masih 66 | Ghanem 67 | Haddad 68 | Isa 69 | Antoun 70 | Sarraf 71 | Sleiman 72 | Dagher 73 | Najjar 74 | Malouf 75 | Nahas 76 | Naser 77 | Saliba 78 | Shamon 79 | Malouf 80 | Kalb 81 | Daher 82 | Maalouf 83 | Wasem 84 | Kanaan 85 | Naifeh 86 | Boutros 87 | Moghadam 88 | Masih 89 | Sleiman 90 | Aswad 91 | Cham 92 | Assaf 93 | Quraishi 94 | Shalhoub 95 | Sabbag 96 | Mifsud 97 | Gaber 98 | Shammas 99 | Tannous 100 | Sleiman 101 | Bazzi 102 | Quraishi 103 | Rahal 104 | Cham 105 | Ghanem 106 | Ghanem 107 | Naser 108 | Baba 109 | Shamon 110 | Almasi 111 | Basara 112 | Quraishi 113 | Bata 114 | Wasem 115 | Shamoun 116 | Deeb 117 | Touma 118 | Asfour 119 | Deeb 120 | Hadad 121 | Naifeh 122 | Touma 123 | Bazzi 124 | Shamoun 125 | Nahas 126 | Haddad 127 | Arian 128 | Kouri 129 | Deeb 130 | Toma 131 | Halabi 132 | Nazari 133 | Saliba 134 | Fakhoury 135 | Hadad 136 | Baba 137 | Mansour 138 | Sayegh 139 | Antar 140 | Deeb 141 | Morcos 142 | Shalhoub 143 | Sarraf 144 | Amari 145 | Wasem 146 | Ganim 147 | Tuma 148 | Fakhoury 149 | Hadad 150 | Hakimi 151 | Nader 152 | Said 153 | Ganim 154 | Daher 155 | Ganem 156 | Tuma 157 | Boutros 158 | Aswad 159 | Sarkis 160 | Daher 161 | Toma 162 | Boutros 163 | Kanaan 164 | Antar 165 | Gerges 166 | Kouri 167 | Maroun 168 | Wasem 169 | Dagher 170 | Naifeh 171 | Bishara 172 | Ba 173 | Cham 174 | Kalb 175 | Bazzi 176 | Bitar 177 | Hadad 178 | Moghadam 179 | Sleiman 180 | Shamoun 181 | Antar 182 | Atiyeh 183 | Koury 184 | Nahas 185 | Kouri 186 | Maroun 187 | Nassar 188 | Sayegh 189 | Haik 190 | Ghanem 191 | Sayegh 192 | Salib 193 | Cham 194 | Bata 195 | Touma 196 | Antoun 197 | Antar 198 | Bata 199 | Botros 200 | Shammas 201 | Ganim 202 | Sleiman 203 | Seif 204 | Moghadam 205 | Ba 206 | Tannous 207 | Bazzi 208 | Seif 209 | Salib 210 | Hadad 211 | Quraishi 212 | Halabi 213 | Essa 214 | Bahar 215 | Kattan 216 | Boutros 217 | Nahas 218 | Sabbagh 219 | Kanaan 220 | Sayegh 221 | Said 222 | Botros 223 | Najjar 224 | Toma 225 | Bata 226 | Atiyeh 227 | Halabi 228 | Tannous 229 | Kouri 230 | Shamoon 231 | Kassis 232 | Haddad 233 | Tuma 234 | Mansour 235 | Antar 236 | Kassis 237 | Kalb 238 | Basara 239 | Rahal 240 | Mansour 241 | Handal 242 | Morcos 243 | Fakhoury 244 | Hadad 245 | Morcos 246 | Kouri 247 | Quraishi 248 | Almasi 249 | Awad 250 | Naifeh 251 | Koury 252 | Asker 253 | Maroun 254 | Fakhoury 255 | Sabbag 256 | Sarraf 257 | Shamon 258 | Assaf 259 | Boutros 260 | Malouf 261 | Nassar 262 | Qureshi 263 | Ghanem 264 | Srour 265 | Almasi 266 | Qureshi 267 | Ghannam 268 | Mustafa 269 | Najjar 270 | Kassab 271 | Shadid 272 | Shamoon 273 | Morcos 274 | Atiyeh 275 | Isa 276 | Ba 277 | Baz 278 | Asker 279 | Seif 280 | Asghar 281 | Hajjar 282 | Deeb 283 | Essa 284 | Qureshi 285 | Abboud 286 | Ganem 287 | Haddad 288 | Koury 289 | Nassar 290 | Abadi 291 | Toma 292 | Tannous 293 | Harb 294 | Issa 295 | Khouri 296 | Mifsud 297 | Kalb 298 | Gaber 299 | Ganim 300 | Boulos 301 | Samaha 302 | Haddad 303 | Sabbag 304 | Wasem 305 | Dagher 306 | Rahal 307 | Atiyeh 308 | Antar 309 | Asghar 310 | Mansour 311 | Awad 312 | Boulos 313 | Sarraf 314 | Deeb 315 | Abadi 316 | Nazari 317 | Daher 318 | Gerges 319 | Shamoon 320 | Gaber 321 | Amari 322 | Sarraf 323 | Nazari 324 | Saliba 325 | Naifeh 326 | Nazari 327 | Hakimi 328 | Shamon 329 | Abboud 330 | Quraishi 331 | Tahan 332 | Safar 333 | Hajjar 334 | Srour 335 | Gaber 336 | Shalhoub 337 | Attia 338 | Safar 339 | Said 340 | Ganem 341 | Nader 342 | Asghar 343 | Mustafa 344 | Said 345 | Antar 346 | Botros 347 | Nader 348 | Ghannam 349 | Asfour 350 | Tahan 351 | Mansour 352 | Attia 353 | Touma 354 | Najjar 355 | Kassis 356 | Abboud 357 | Bishara 358 | Bazzi 359 | Shalhoub 360 | Shalhoub 361 | Safar 362 | Khoury 363 | Nazari 364 | Sabbag 365 | Sleiman 366 | Atiyeh 367 | Kouri 368 | Bitar 369 | Zogby 370 | Ghanem 371 | Assaf 372 | Abadi 373 | Arian 374 | Shalhoub 375 | Khoury 376 | Morcos 377 | Shamon 378 | Wasem 379 | Abadi 380 | Antoun 381 | Baz 382 | Naser 383 | Assaf 384 | Saliba 385 | Nader 386 | Mikhail 387 | Naser 388 | Daher 389 | Morcos 390 | Awad 391 | Nahas 392 | Sarkis 393 | Malouf 394 | Mustafa 395 | Fakhoury 396 | Ghannam 397 | Shadid 398 | Gaber 399 | Koury 400 | Atiyeh 401 | Shamon 402 | Boutros 403 | Sarraf 404 | Arian 405 | Fakhoury 406 | Abadi 407 | Kassab 408 | Nahas 409 | Quraishi 410 | Mansour 411 | Samaha 412 | Wasem 413 | Seif 414 | Fakhoury 415 | Saliba 416 | Cham 417 | Bahar 418 | Shamoun 419 | Essa 420 | Shamon 421 | Asfour 422 | Bitar 423 | Cham 424 | Tahan 425 | Tannous 426 | Daher 427 | Khoury 428 | Shamon 429 | Bahar 430 | Quraishi 431 | Ghannam 432 | Kassab 433 | Zogby 434 | Basara 435 | Shammas 436 | Arian 437 | Sayegh 438 | Naifeh 439 | Mifsud 440 | Sleiman 441 | Arian 442 | Kassis 443 | Shamoun 444 | Kassis 445 | Harb 446 | Mustafa 447 | Boulos 448 | Asghar 449 | Shamon 450 | Kanaan 451 | Atiyeh 452 | Kassab 453 | Tahan 454 | Bazzi 455 | Kassis 456 | Qureshi 457 | Basara 458 | Shalhoub 459 | Sayegh 460 | Haik 461 | Attia 462 | Maroun 463 | Kassis 464 | Sarkis 465 | Harb 466 | Assaf 467 | Kattan 468 | Antar 469 | Sleiman 470 | Touma 471 | Sarraf 472 | Bazzi 473 | Boulos 474 | Baz 475 | Issa 476 | Shamon 477 | Shadid 478 | Deeb 479 | Sabbag 480 | Wasem 481 | Awad 482 | Mansour 483 | Saliba 484 | Fakhoury 485 | Arian 486 | Bishara 487 | Dagher 488 | Bishara 489 | Koury 490 | Fakhoury 491 | Naser 492 | Nader 493 | Antar 494 | Gerges 495 | Handal 496 | Hanania 497 | Shadid 498 | Gerges 499 | Kassis 500 | Essa 501 | Assaf 502 | Shadid 503 | Seif 504 | Shalhoub 505 | Shamoun 506 | Hajjar 507 | Baba 508 | Sayegh 509 | Mustafa 510 | Sabbagh 511 | Isa 512 | Najjar 513 | Tannous 514 | Hanania 515 | Ganem 516 | Gerges 517 | Fakhoury 518 | Mifsud 519 | Nahas 520 | Bishara 521 | Bishara 522 | Abadi 523 | Sarkis 524 | Masih 525 | Isa 526 | Attia 527 | Kalb 528 | Essa 529 | Boulos 530 | Basara 531 | Halabi 532 | Halabi 533 | Dagher 534 | Attia 535 | Kassis 536 | Tuma 537 | Gerges 538 | Ghannam 539 | Toma 540 | Baz 541 | Asghar 542 | Zogby 543 | Aswad 544 | Hadad 545 | Dagher 546 | Naser 547 | Shadid 548 | Atiyeh 549 | Zogby 550 | Abboud 551 | Tannous 552 | Khouri 553 | Atiyeh 554 | Ganem 555 | Maalouf 556 | Isa 557 | Maroun 558 | Issa 559 | Khouri 560 | Harb 561 | Nader 562 | Awad 563 | Nahas 564 | Said 565 | Baba 566 | Totah 567 | Ganim 568 | Handal 569 | Mansour 570 | Basara 571 | Malouf 572 | Said 573 | Botros 574 | Samaha 575 | Safar 576 | Tahan 577 | Botros 578 | Shamoun 579 | Handal 580 | Sarraf 581 | Malouf 582 | Bishara 583 | Aswad 584 | Khouri 585 | Baz 586 | Asker 587 | Toma 588 | Koury 589 | Gerges 590 | Bishara 591 | Boulos 592 | Najjar 593 | Aswad 594 | Shamon 595 | Kouri 596 | Srour 597 | Assaf 598 | Tannous 599 | Attia 600 | Mustafa 601 | Kattan 602 | Asghar 603 | Amari 604 | Shadid 605 | Said 606 | Bazzi 607 | Masih 608 | Antar 609 | Fakhoury 610 | Shadid 611 | Masih 612 | Handal 613 | Sarraf 614 | Kassis 615 | Salib 616 | Hajjar 617 | Totah 618 | Koury 619 | Totah 620 | Mustafa 621 | Sabbagh 622 | Moghadam 623 | Toma 624 | Srour 625 | Almasi 626 | Totah 627 | Maroun 628 | Kattan 629 | Naifeh 630 | Sarkis 631 | Mikhail 632 | Nazari 633 | Boutros 634 | Guirguis 635 | Gaber 636 | Kassis 637 | Masih 638 | Hanania 639 | Maloof 640 | Quraishi 641 | Cham 642 | Hadad 643 | Tahan 644 | Bitar 645 | Arian 646 | Gaber 647 | Baz 648 | Mansour 649 | Kalb 650 | Sarkis 651 | Attia 652 | Antar 653 | Asfour 654 | Said 655 | Essa 656 | Koury 657 | Hadad 658 | Tuma 659 | Moghadam 660 | Sabbagh 661 | Amari 662 | Dagher 663 | Srour 664 | Antoun 665 | Sleiman 666 | Maroun 667 | Tuma 668 | Nahas 669 | Hanania 670 | Sayegh 671 | Amari 672 | Sabbagh 673 | Said 674 | Cham 675 | Asker 676 | Nassar 677 | Bitar 678 | Said 679 | Dagher 680 | Safar 681 | Khouri 682 | Totah 683 | Khoury 684 | Salib 685 | Basara 686 | Abboud 687 | Baz 688 | Isa 689 | Cham 690 | Amari 691 | Mifsud 692 | Hadad 693 | Rahal 694 | Khoury 695 | Bazzi 696 | Basara 697 | Totah 698 | Ghannam 699 | Koury 700 | Malouf 701 | Zogby 702 | Zogby 703 | Boutros 704 | Nassar 705 | Handal 706 | Hajjar 707 | Maloof 708 | Abadi 709 | Maroun 710 | Mifsud 711 | Kalb 712 | Amari 713 | Hakimi 714 | Boutros 715 | Masih 716 | Kattan 717 | Haddad 718 | Arian 719 | Nazari 720 | Assaf 721 | Attia 722 | Wasem 723 | Gerges 724 | Asker 725 | Tahan 726 | Fakhoury 727 | Shadid 728 | Sarraf 729 | Attia 730 | Naifeh 731 | Aswad 732 | Deeb 733 | Tannous 734 | Totah 735 | Cham 736 | Baba 737 | Najjar 738 | Hajjar 739 | Shamoon 740 | Handal 741 | Awad 742 | Guirguis 743 | Awad 744 | Ganem 745 | Naifeh 746 | Khoury 747 | Hajjar 748 | Moghadam 749 | Mikhail 750 | Ghannam 751 | Guirguis 752 | Tannous 753 | Kanaan 754 | Handal 755 | Khoury 756 | Kalb 757 | Qureshi 758 | Najjar 759 | Atiyeh 760 | Gerges 761 | Nassar 762 | Tahan 763 | Hadad 764 | Fakhoury 765 | Salib 766 | Wasem 767 | Bitar 768 | Fakhoury 769 | Attia 770 | Awad 771 | Totah 772 | Deeb 773 | Touma 774 | Botros 775 | Nazari 776 | Nahas 777 | Kouri 778 | Ghannam 779 | Assaf 780 | Asfour 781 | Sarraf 782 | Naifeh 783 | Toma 784 | Asghar 785 | Abboud 786 | Issa 787 | Sabbag 788 | Sabbagh 789 | Isa 790 | Koury 791 | Kattan 792 | Shamoon 793 | Rahal 794 | Kalb 795 | Naser 796 | Masih 797 | Sayegh 798 | Dagher 799 | Asker 800 | Maroun 801 | Dagher 802 | Sleiman 803 | Botros 804 | Sleiman 805 | Harb 806 | Tahan 807 | Tuma 808 | Said 809 | Hadad 810 | Samaha 811 | Harb 812 | Cham 813 | Atiyeh 814 | Haik 815 | Malouf 816 | Bazzi 817 | Harb 818 | Malouf 819 | Ghanem 820 | Cham 821 | Asghar 822 | Samaha 823 | Khouri 824 | Nassar 825 | Rahal 826 | Baz 827 | Kalb 828 | Rahal 829 | Gerges 830 | Cham 831 | Sayegh 832 | Shadid 833 | Morcos 834 | Shamoon 835 | Hakimi 836 | Shamoon 837 | Qureshi 838 | Ganim 839 | Shadid 840 | Khoury 841 | Boutros 842 | Hanania 843 | Antoun 844 | Naifeh 845 | Deeb 846 | Samaha 847 | Awad 848 | Asghar 849 | Awad 850 | Saliba 851 | Shamoun 852 | Mikhail 853 | Hakimi 854 | Mikhail 855 | Cham 856 | Halabi 857 | Sarkis 858 | Kattan 859 | Nazari 860 | Safar 861 | Morcos 862 | Khoury 863 | Essa 864 | Nassar 865 | Haik 866 | Shadid 867 | Fakhoury 868 | Najjar 869 | Arian 870 | Botros 871 | Daher 872 | Saliba 873 | Saliba 874 | Kattan 875 | Hajjar 876 | Nader 877 | Daher 878 | Nassar 879 | Maroun 880 | Harb 881 | Nassar 882 | Antar 883 | Shammas 884 | Toma 885 | Antar 886 | Koury 887 | Nader 888 | Botros 889 | Bahar 890 | Najjar 891 | Maloof 892 | Salib 893 | Malouf 894 | Mansour 895 | Bazzi 896 | Atiyeh 897 | Kanaan 898 | Bishara 899 | Hakimi 900 | Saliba 901 | Tuma 902 | Mifsud 903 | Hakimi 904 | Assaf 905 | Nassar 906 | Sarkis 907 | Bitar 908 | Isa 909 | Halabi 910 | Shamon 911 | Qureshi 912 | Bishara 913 | Maalouf 914 | Srour 915 | Boulos 916 | Safar 917 | Shamoun 918 | Ganim 919 | Abadi 920 | Koury 921 | Shadid 922 | Zogby 923 | Boutros 924 | Shadid 925 | Hakimi 926 | Bazzi 927 | Isa 928 | Totah 929 | Salib 930 | Shamoon 931 | Gaber 932 | Antar 933 | Antar 934 | Najjar 935 | Fakhoury 936 | Malouf 937 | Salib 938 | Rahal 939 | Boulos 940 | Attia 941 | Said 942 | Kassis 943 | Bahar 944 | Bazzi 945 | Srour 946 | Antar 947 | Nahas 948 | Kassis 949 | Samaha 950 | Quraishi 951 | Asghar 952 | Asker 953 | Antar 954 | Totah 955 | Haddad 956 | Maloof 957 | Kouri 958 | Basara 959 | Bata 960 | Antar 961 | Shammas 962 | Arian 963 | Gerges 964 | Seif 965 | Almasi 966 | Tuma 967 | Shamoon 968 | Khoury 969 | Hakimi 970 | Abboud 971 | Baz 972 | Seif 973 | Issa 974 | Nazari 975 | Harb 976 | Shammas 977 | Amari 978 | Totah 979 | Malouf 980 | Sarkis 981 | Naser 982 | Zogby 983 | Handal 984 | Naifeh 985 | Cham 986 | Hadad 987 | Gerges 988 | Kalb 989 | Shalhoub 990 | Saliba 991 | Tannous 992 | Tahan 993 | Tannous 994 | Kassis 995 | Shadid 996 | Sabbag 997 | Tahan 998 | Abboud 999 | Nahas 1000 | Shamoun 1001 | Dagher 1002 | Botros 1003 | Amari 1004 | Maalouf 1005 | Awad 1006 | Gerges 1007 | Shamoon 1008 | Haddad 1009 | Salib 1010 | Attia 1011 | Kassis 1012 | Sleiman 1013 | Maloof 1014 | Maroun 1015 | Koury 1016 | Asghar 1017 | Kalb 1018 | Asghar 1019 | Touma 1020 | Ganim 1021 | Rahal 1022 | Haddad 1023 | Zogby 1024 | Mansour 1025 | Guirguis 1026 | Touma 1027 | Maroun 1028 | Tannous 1029 | Hakimi 1030 | Baba 1031 | Toma 1032 | Botros 1033 | Sarraf 1034 | Koury 1035 | Sarraf 1036 | Nassar 1037 | Boutros 1038 | Guirguis 1039 | Qureshi 1040 | Aswad 1041 | Basara 1042 | Toma 1043 | Tuma 1044 | Mansour 1045 | Ba 1046 | Naifeh 1047 | Mikhail 1048 | Amari 1049 | Shamon 1050 | Malouf 1051 | Boutros 1052 | Hakimi 1053 | Srour 1054 | Morcos 1055 | Halabi 1056 | Bazzi 1057 | Abadi 1058 | Shamoun 1059 | Haddad 1060 | Baz 1061 | Baba 1062 | Hadad 1063 | Saliba 1064 | Haddad 1065 | Maalouf 1066 | Bitar 1067 | Shammas 1068 | Totah 1069 | Said 1070 | Najjar 1071 | Mikhail 1072 | Samaha 1073 | Boulos 1074 | Kalb 1075 | Shamon 1076 | Shamoun 1077 | Seif 1078 | Touma 1079 | Hajjar 1080 | Hadad 1081 | Atiyeh 1082 | Totah 1083 | Mansour 1084 | Nazari 1085 | Quraishi 1086 | Ba 1087 | Sarkis 1088 | Gerges 1089 | Shalhoub 1090 | Nazari 1091 | Issa 1092 | Salib 1093 | Shalhoub 1094 | Nassar 1095 | Guirguis 1096 | Daher 1097 | Hakimi 1098 | Attia 1099 | Cham 1100 | Isa 1101 | Hakimi 1102 | Amari 1103 | Boutros 1104 | Sarraf 1105 | Antoun 1106 | Botros 1107 | Haddad 1108 | Tahan 1109 | Bishara 1110 | Shalhoub 1111 | Safar 1112 | Haik 1113 | Tahan 1114 | Seif 1115 | Awad 1116 | Antoun 1117 | Atiyeh 1118 | Samaha 1119 | Assaf 1120 | Guirguis 1121 | Hadad 1122 | Sayegh 1123 | Khouri 1124 | Asghar 1125 | Tannous 1126 | Maalouf 1127 | Khouri 1128 | Hajjar 1129 | Abadi 1130 | Ghanem 1131 | Salib 1132 | Botros 1133 | Bitar 1134 | Bishara 1135 | Quraishi 1136 | Boutros 1137 | Aswad 1138 | Srour 1139 | Shamon 1140 | Abboud 1141 | Almasi 1142 | Baba 1143 | Tahan 1144 | Essa 1145 | Sabbag 1146 | Issa 1147 | Abadi 1148 | Abboud 1149 | Bazzi 1150 | Nader 1151 | Bahar 1152 | Ghannam 1153 | Asghar 1154 | Gaber 1155 | Sayegh 1156 | Guirguis 1157 | Srour 1158 | Asghar 1159 | Quraishi 1160 | Sayegh 1161 | Rahal 1162 | Tahan 1163 | Morcos 1164 | Cham 1165 | Kanaan 1166 | Nahas 1167 | Essa 1168 | Mifsud 1169 | Kouri 1170 | Isa 1171 | Saliba 1172 | Asfour 1173 | Guirguis 1174 | Isa 1175 | Bishara 1176 | Assaf 1177 | Naser 1178 | Moghadam 1179 | Kalb 1180 | Baba 1181 | Guirguis 1182 | Naifeh 1183 | Bitar 1184 | Samaha 1185 | Abboud 1186 | Hadad 1187 | Ghannam 1188 | Hanania 1189 | Shadid 1190 | Totah 1191 | Tahan 1192 | Toma 1193 | Maloof 1194 | Botros 1195 | Issa 1196 | Deeb 1197 | Nahas 1198 | Khoury 1199 | Sayegh 1200 | Harb 1201 | Said 1202 | Guirguis 1203 | Nader 1204 | Harb 1205 | Atiyeh 1206 | Zogby 1207 | Basara 1208 | Nassar 1209 | Kalb 1210 | Khoury 1211 | Mifsud 1212 | Wasem 1213 | Handal 1214 | Ganim 1215 | Harb 1216 | Ganim 1217 | Malouf 1218 | Sayegh 1219 | Khoury 1220 | Sabbag 1221 | Sabbag 1222 | Boulos 1223 | Malouf 1224 | Gaber 1225 | Shammas 1226 | Fakhoury 1227 | Halabi 1228 | Haddad 1229 | Asker 1230 | Morcos 1231 | Hanania 1232 | Amari 1233 | Kassab 1234 | Malouf 1235 | Khouri 1236 | Moghadam 1237 | Totah 1238 | Maloof 1239 | Atiyeh 1240 | Abadi 1241 | Baz 1242 | Khoury 1243 | Arian 1244 | Handal 1245 | Dagher 1246 | Awad 1247 | Atiyeh 1248 | Arian 1249 | Khoury 1250 | Amari 1251 | Attia 1252 | Ganim 1253 | Nader 1254 | Dagher 1255 | Sabbag 1256 | Halabi 1257 | Khouri 1258 | Khouri 1259 | Saliba 1260 | Mifsud 1261 | Koury 1262 | Awad 1263 | Bahar 1264 | Mustafa 1265 | Kassis 1266 | Gaber 1267 | Mifsud 1268 | Bishara 1269 | Asker 1270 | Nahas 1271 | Wasem 1272 | Sleiman 1273 | Bata 1274 | Daher 1275 | Antar 1276 | Isa 1277 | Ganim 1278 | Rahal 1279 | Toma 1280 | Rahal 1281 | Shamoun 1282 | Maloof 1283 | Hakimi 1284 | Safar 1285 | Gerges 1286 | Hanania 1287 | Koury 1288 | Assaf 1289 | Safar 1290 | Gerges 1291 | Ganim 1292 | Morcos 1293 | Awad 1294 | Arian 1295 | Tahan 1296 | Sleiman 1297 | Asker 1298 | Boulos 1299 | Koury 1300 | Mifsud 1301 | Sabbag 1302 | Dagher 1303 | Bazzi 1304 | Mustafa 1305 | Almasi 1306 | Handal 1307 | Isa 1308 | Guirguis 1309 | Sayegh 1310 | Ganim 1311 | Ghanem 1312 | Toma 1313 | Mustafa 1314 | Basara 1315 | Bitar 1316 | Samaha 1317 | Mifsud 1318 | Tahan 1319 | Issa 1320 | Salib 1321 | Khoury 1322 | Hadad 1323 | Haik 1324 | Gaber 1325 | Mansour 1326 | Hakimi 1327 | Ba 1328 | Mustafa 1329 | Gaber 1330 | Kattan 1331 | Koury 1332 | Awad 1333 | Maalouf 1334 | Masih 1335 | Harb 1336 | Atiyeh 1337 | Zogby 1338 | Nahas 1339 | Assaf 1340 | Morcos 1341 | Ganem 1342 | Ganem 1343 | Wasem 1344 | Fakhoury 1345 | Ghanem 1346 | Salib 1347 | Khouri 1348 | Maloof 1349 | Khouri 1350 | Shalhoub 1351 | Issa 1352 | Najjar 1353 | Kassis 1354 | Mustafa 1355 | Sayegh 1356 | Kassis 1357 | Hajjar 1358 | Nader 1359 | Sarkis 1360 | Tahan 1361 | Haddad 1362 | Antar 1363 | Sayegh 1364 | Zogby 1365 | Mifsud 1366 | Kassab 1367 | Hanania 1368 | Bishara 1369 | Shamoun 1370 | Abboud 1371 | Mustafa 1372 | Sleiman 1373 | Abadi 1374 | Sarraf 1375 | Zogby 1376 | Daher 1377 | Issa 1378 | Nazari 1379 | Shamon 1380 | Tuma 1381 | Asghar 1382 | Morcos 1383 | Mifsud 1384 | Cham 1385 | Sarraf 1386 | Antar 1387 | Ba 1388 | Aswad 1389 | Mikhail 1390 | Kouri 1391 | Mikhail 1392 | Awad 1393 | Halabi 1394 | Moghadam 1395 | Mikhail 1396 | Naifeh 1397 | Kattan 1398 | Shammas 1399 | Malouf 1400 | Najjar 1401 | Srour 1402 | Masih 1403 | Fakhoury 1404 | Khouri 1405 | Assaf 1406 | Mifsud 1407 | Malouf 1408 | Abboud 1409 | Shamoon 1410 | Mansour 1411 | Halabi 1412 | Ganem 1413 | Deeb 1414 | Wasem 1415 | Kalb 1416 | Safar 1417 | Tuma 1418 | Fakhoury 1419 | Toma 1420 | Guirguis 1421 | Kassab 1422 | Nader 1423 | Handal 1424 | Baba 1425 | Fakhoury 1426 | Haik 1427 | Guirguis 1428 | Seif 1429 | Almasi 1430 | Shamon 1431 | Ba 1432 | Salib 1433 | Zogby 1434 | Koury 1435 | Najjar 1436 | Atiyeh 1437 | Morcos 1438 | Antar 1439 | Awad 1440 | Hadad 1441 | Maroun 1442 | Touma 1443 | Almasi 1444 | Kassis 1445 | Arian 1446 | Malouf 1447 | Koury 1448 | Sarraf 1449 | Hadad 1450 | Bata 1451 | Tuma 1452 | Sarkis 1453 | Quraishi 1454 | Gaber 1455 | Abadi 1456 | Nader 1457 | Bazzi 1458 | Ghannam 1459 | Botros 1460 | Deeb 1461 | Awad 1462 | Kattan 1463 | Kanaan 1464 | Sarraf 1465 | Nahas 1466 | Assaf 1467 | Shadid 1468 | Gaber 1469 | Samaha 1470 | Harb 1471 | Samaha 1472 | Zogby 1473 | Atiyeh 1474 | Mustafa 1475 | Hanania 1476 | Isa 1477 | Almasi 1478 | Bitar 1479 | Fakhoury 1480 | Moghadam 1481 | Handal 1482 | Seif 1483 | Mustafa 1484 | Rahal 1485 | Antoun 1486 | Kassab 1487 | Bazzi 1488 | Hadad 1489 | Nader 1490 | Tuma 1491 | Basara 1492 | Totah 1493 | Nassar 1494 | Seif 1495 | Nassar 1496 | Daher 1497 | Daher 1498 | Maalouf 1499 | Rahal 1500 | Quraishi 1501 | Hadad 1502 | Bahar 1503 | Sabbag 1504 | Halabi 1505 | Tuma 1506 | Antoun 1507 | Boutros 1508 | Gerges 1509 | Bishara 1510 | Baba 1511 | Zogby 1512 | Nahas 1513 | Atiyeh 1514 | Rahal 1515 | Sabbagh 1516 | Bitar 1517 | Botros 1518 | Tuma 1519 | Ganim 1520 | Handal 1521 | Daher 1522 | Boutros 1523 | Khouri 1524 | Maroun 1525 | Mifsud 1526 | Arian 1527 | Safar 1528 | Koury 1529 | Deeb 1530 | Shamoun 1531 | Cham 1532 | Asghar 1533 | Morcos 1534 | Tahan 1535 | Salib 1536 | Aswad 1537 | Shadid 1538 | Saliba 1539 | Ganim 1540 | Haik 1541 | Kattan 1542 | Antoun 1543 | Hajjar 1544 | Toma 1545 | Toma 1546 | Antoun 1547 | Tahan 1548 | Haik 1549 | Kassis 1550 | Shamoun 1551 | Shammas 1552 | Kassis 1553 | Shadid 1554 | Samaha 1555 | Sarraf 1556 | Nader 1557 | Ganem 1558 | Zogby 1559 | Maloof 1560 | Kalb 1561 | Gerges 1562 | Seif 1563 | Nahas 1564 | Arian 1565 | Asfour 1566 | Hakimi 1567 | Ba 1568 | Handal 1569 | Abadi 1570 | Harb 1571 | Nader 1572 | Asghar 1573 | Sabbag 1574 | Touma 1575 | Amari 1576 | Kanaan 1577 | Hajjar 1578 | Said 1579 | Sarraf 1580 | Haddad 1581 | Mifsud 1582 | Shammas 1583 | Sleiman 1584 | Asfour 1585 | Deeb 1586 | Kattan 1587 | Naser 1588 | Said 1589 | Bishara 1590 | Harb 1591 | Morcos 1592 | Sayegh 1593 | Said 1594 | Naser 1595 | Aswad 1596 | Seif 1597 | Kouri 1598 | Dagher 1599 | Shamon 1600 | Hadad 1601 | Handal 1602 | Tuma 1603 | Shamon 1604 | Hakimi 1605 | Rahal 1606 | Hadad 1607 | Ghannam 1608 | Almasi 1609 | Daher 1610 | Handal 1611 | Malouf 1612 | Mansour 1613 | Sabbagh 1614 | Sabbag 1615 | Saliba 1616 | Haddad 1617 | Tahan 1618 | Khoury 1619 | Harb 1620 | Ganim 1621 | Mansour 1622 | Ganem 1623 | Handal 1624 | Handal 1625 | Antar 1626 | Asfour 1627 | Kouri 1628 | Cham 1629 | Masih 1630 | Saliba 1631 | Qureshi 1632 | Daher 1633 | Safar 1634 | Assaf 1635 | Harb 1636 | Abboud 1637 | Haik 1638 | Ghannam 1639 | Maalouf 1640 | Daher 1641 | Najjar 1642 | Mifsud 1643 | Daher 1644 | Amari 1645 | Saliba 1646 | Kanaan 1647 | Guirguis 1648 | Atiyeh 1649 | Sleiman 1650 | Mikhail 1651 | Arian 1652 | Wasem 1653 | Attia 1654 | Nassar 1655 | Cham 1656 | Koury 1657 | Baba 1658 | Guirguis 1659 | Morcos 1660 | Quraishi 1661 | Seif 1662 | Sarkis 1663 | Moghadam 1664 | Ba 1665 | Boutros 1666 | Nader 1667 | Gerges 1668 | Salib 1669 | Salib 1670 | Guirguis 1671 | Essa 1672 | Guirguis 1673 | Antoun 1674 | Kassis 1675 | Abboud 1676 | Najjar 1677 | Aswad 1678 | Srour 1679 | Mifsud 1680 | Ghanem 1681 | Bitar 1682 | Ghannam 1683 | Asghar 1684 | Deeb 1685 | Kalb 1686 | Nader 1687 | Srour 1688 | Attia 1689 | Shamon 1690 | Bata 1691 | Nahas 1692 | Gerges 1693 | Kanaan 1694 | Kassis 1695 | Sarkis 1696 | Maloof 1697 | Almasi 1698 | Nassar 1699 | Saliba 1700 | Arian 1701 | Ghanem 1702 | Awad 1703 | Naifeh 1704 | Boutros 1705 | Fakhoury 1706 | Sabbag 1707 | Antar 1708 | Tahan 1709 | Mustafa 1710 | Almasi 1711 | Shammas 1712 | Totah 1713 | Boutros 1714 | Cham 1715 | Shamon 1716 | Ganim 1717 | Ghanem 1718 | Assaf 1719 | Khoury 1720 | Naifeh 1721 | Bahar 1722 | Quraishi 1723 | Bishara 1724 | Cham 1725 | Asfour 1726 | Ghannam 1727 | Khoury 1728 | Sayegh 1729 | Hanania 1730 | Maroun 1731 | Kouri 1732 | Sarkis 1733 | Haik 1734 | Basara 1735 | Salib 1736 | Shammas 1737 | Fakhoury 1738 | Nahas 1739 | Ganim 1740 | Botros 1741 | Arian 1742 | Shalhoub 1743 | Hadad 1744 | Mustafa 1745 | Shalhoub 1746 | Kassab 1747 | Asker 1748 | Botros 1749 | Kanaan 1750 | Gaber 1751 | Bazzi 1752 | Sayegh 1753 | Nassar 1754 | Kassis 1755 | Fakhoury 1756 | Kassis 1757 | Amari 1758 | Sarraf 1759 | Mifsud 1760 | Salib 1761 | Samaha 1762 | Mustafa 1763 | Asfour 1764 | Najjar 1765 | Essa 1766 | Naifeh 1767 | Cham 1768 | Sarraf 1769 | Moghadam 1770 | Fakhoury 1771 | Assaf 1772 | Almasi 1773 | Asghar 1774 | Nader 1775 | Kalb 1776 | Shamoun 1777 | Gerges 1778 | Wasem 1779 | Morcos 1780 | Nader 1781 | Said 1782 | Safar 1783 | Quraishi 1784 | Samaha 1785 | Kassab 1786 | Deeb 1787 | Sarraf 1788 | Rahal 1789 | Naifeh 1790 | Ba 1791 | Nazari 1792 | Ganim 1793 | Arian 1794 | Asker 1795 | Touma 1796 | Kassab 1797 | Tahan 1798 | Mansour 1799 | Morcos 1800 | Shammas 1801 | Baba 1802 | Morcos 1803 | Isa 1804 | Moghadam 1805 | Ganem 1806 | Baz 1807 | Totah 1808 | Nader 1809 | Kouri 1810 | Guirguis 1811 | Koury 1812 | Zogby 1813 | Basara 1814 | Baz 1815 | Deeb 1816 | Mustafa 1817 | Shadid 1818 | Awad 1819 | Sarraf 1820 | Quraishi 1821 | Kanaan 1822 | Tahan 1823 | Ghannam 1824 | Shammas 1825 | Abboud 1826 | Najjar 1827 | Bishara 1828 | Tuma 1829 | Srour 1830 | Mifsud 1831 | Srour 1832 | Hajjar 1833 | Qureshi 1834 | Bitar 1835 | Hadad 1836 | Almasi 1837 | Wasem 1838 | Abadi 1839 | Maroun 1840 | Baz 1841 | Koury 1842 | Ganem 1843 | Awad 1844 | Maalouf 1845 | Mifsud 1846 | Haik 1847 | Sleiman 1848 | Arian 1849 | Seif 1850 | Mansour 1851 | Koury 1852 | Kattan 1853 | Koury 1854 | Aswad 1855 | Ba 1856 | Rahal 1857 | Zogby 1858 | Bahar 1859 | Fakhoury 1860 | Samaha 1861 | Sarraf 1862 | Mifsud 1863 | Antar 1864 | Moghadam 1865 | Botros 1866 | Srour 1867 | Sabbag 1868 | Sayegh 1869 | Rahal 1870 | Attia 1871 | Naifeh 1872 | Saliba 1873 | Mustafa 1874 | Amari 1875 | Issa 1876 | Masih 1877 | Khouri 1878 | Haddad 1879 | Kalb 1880 | Bazzi 1881 | Salib 1882 | Hanania 1883 | Shamoon 1884 | Tuma 1885 | Cham 1886 | Antoun 1887 | Wasem 1888 | Kouri 1889 | Ghanem 1890 | Wasem 1891 | Khoury 1892 | Assaf 1893 | Ganem 1894 | Seif 1895 | Nader 1896 | Essa 1897 | Shadid 1898 | Botros 1899 | Sleiman 1900 | Bishara 1901 | Basara 1902 | Maalouf 1903 | Issa 1904 | Nassar 1905 | Moghadam 1906 | Ganim 1907 | Kassis 1908 | Antoun 1909 | Said 1910 | Khouri 1911 | Salib 1912 | Baz 1913 | Sarkis 1914 | Tuma 1915 | Naifeh 1916 | Najjar 1917 | Asker 1918 | Khouri 1919 | Mustafa 1920 | Najjar 1921 | Sabbag 1922 | Malouf 1923 | Wasem 1924 | Maalouf 1925 | Gaber 1926 | Said 1927 | Zogby 1928 | Bahar 1929 | Hanania 1930 | Shalhoub 1931 | Abadi 1932 | Handal 1933 | Qureshi 1934 | Kanaan 1935 | Abboud 1936 | Mifsud 1937 | Touma 1938 | Ganim 1939 | Bishara 1940 | Bazzi 1941 | Gaber 1942 | Haik 1943 | Ghanem 1944 | Sarraf 1945 | Sarkis 1946 | Mustafa 1947 | Baz 1948 | Kanaan 1949 | Nazari 1950 | Bahar 1951 | Malouf 1952 | Quraishi 1953 | Kattan 1954 | Arian 1955 | Shadid 1956 | Tuma 1957 | Nader 1958 | Khoury 1959 | Safar 1960 | Wasem 1961 | Toma 1962 | Haddad 1963 | Quraishi 1964 | Nassar 1965 | Kanaan 1966 | Gaber 1967 | Haddad 1968 | Rahal 1969 | Koury 1970 | Harb 1971 | Mikhail 1972 | Dagher 1973 | Shadid 1974 | Boutros 1975 | Mikhail 1976 | Khouri 1977 | Nader 1978 | Issa 1979 | Harb 1980 | Dagher 1981 | Gerges 1982 | Morcos 1983 | Essa 1984 | Fakhoury 1985 | Tuma 1986 | Kattan 1987 | Totah 1988 | Qureshi 1989 | Nahas 1990 | Bitar 1991 | Tahan 1992 | Daher 1993 | Shammas 1994 | Kouri 1995 | Ganim 1996 | Daher 1997 | Awad 1998 | Malouf 1999 | Mustafa 2000 | Aswad 2001 | -------------------------------------------------------------------------------- /data/names/Chinese.txt: -------------------------------------------------------------------------------- 1 | Ang 2 | Au-Yong 3 | Bai 4 | Ban 5 | Bao 6 | Bei 7 | Bian 8 | Bui 9 | Cai 10 | Cao 11 | Cen 12 | Chai 13 | Chaim 14 | Chan 15 | Chang 16 | Chao 17 | Che 18 | Chen 19 | Cheng 20 | Cheung 21 | Chew 22 | Chieu 23 | Chin 24 | Chong 25 | Chou 26 | Chu 27 | Cui 28 | Dai 29 | Deng 30 | Ding 31 | Dong 32 | Dou 33 | Duan 34 | Eng 35 | Fan 36 | Fei 37 | Feng 38 | Foong 39 | Fung 40 | Gan 41 | Gauk 42 | Geng 43 | Gim 44 | Gok 45 | Gong 46 | Guan 47 | Guang 48 | Guo 49 | Gwock 50 | Han 51 | Hang 52 | Hao 53 | Hew 54 | Hiu 55 | Hong 56 | Hor 57 | Hsiao 58 | Hua 59 | Huan 60 | Huang 61 | Hui 62 | Huie 63 | Huo 64 | Jia 65 | Jiang 66 | Jin 67 | Jing 68 | Joe 69 | Kang 70 | Kau 71 | Khoo 72 | Khu 73 | Kong 74 | Koo 75 | Kwan 76 | Kwei 77 | Kwong 78 | Lai 79 | Lam 80 | Lang 81 | Lau 82 | Law 83 | Lew 84 | Lian 85 | Liao 86 | Lim 87 | Lin 88 | Ling 89 | Liu 90 | Loh 91 | Long 92 | Loong 93 | Luo 94 | Mah 95 | Mai 96 | Mak 97 | Mao 98 | Mar 99 | Mei 100 | Meng 101 | Miao 102 | Min 103 | Ming 104 | Moy 105 | Mui 106 | Nie 107 | Niu 108 | Ou-Yang 109 | Ow-Yang 110 | Pan 111 | Pang 112 | Pei 113 | Peng 114 | Ping 115 | Qian 116 | Qin 117 | Qiu 118 | Quan 119 | Que 120 | Ran 121 | Rao 122 | Rong 123 | Ruan 124 | Sam 125 | Seah 126 | See 127 | Seow 128 | Seto 129 | Sha 130 | Shan 131 | Shang 132 | Shao 133 | Shaw 134 | She 135 | Shen 136 | Sheng 137 | Shi 138 | Shu 139 | Shuai 140 | Shui 141 | Shum 142 | Siew 143 | Siu 144 | Song 145 | Sum 146 | Sun 147 | Sze 148 | Tan 149 | Tang 150 | Tao 151 | Teng 152 | Teoh 153 | Thean 154 | Thian 155 | Thien 156 | Tian 157 | Tong 158 | Tow 159 | Tsang 160 | Tse 161 | Tsen 162 | Tso 163 | Tze 164 | Wan 165 | Wang 166 | Wei 167 | Wen 168 | Weng 169 | Won 170 | Wong 171 | Woo 172 | Xiang 173 | Xiao 174 | Xie 175 | Xing 176 | Xue 177 | Xun 178 | Yan 179 | Yang 180 | Yao 181 | Yap 182 | Yau 183 | Yee 184 | Yep 185 | Yim 186 | Yin 187 | Ying 188 | Yong 189 | You 190 | Yuan 191 | Zang 192 | Zeng 193 | Zha 194 | Zhan 195 | Zhang 196 | Zhao 197 | Zhen 198 | Zheng 199 | Zhong 200 | Zhou 201 | Zhu 202 | Zhuo 203 | Zong 204 | Zou 205 | Bing 206 | Chi 207 | Chu 208 | Cong 209 | Cuan 210 | Dan 211 | Fei 212 | Feng 213 | Gai 214 | Gao 215 | Gou 216 | Guan 217 | Gui 218 | Guo 219 | Hong 220 | Hou 221 | Huan 222 | Jian 223 | Jiao 224 | Jin 225 | Jiu 226 | Juan 227 | Jue 228 | Kan 229 | Kuai 230 | Kuang 231 | Kui 232 | Lao 233 | Liang 234 | Lu 235 | Luo 236 | Man 237 | Nao 238 | Pian 239 | Qiao 240 | Qing 241 | Qiu 242 | Rang 243 | Rui 244 | She 245 | Shi 246 | Shuo 247 | Sui 248 | Tai 249 | Wan 250 | Wei 251 | Xian 252 | Xie 253 | Xin 254 | Xing 255 | Xiong 256 | Xuan 257 | Yan 258 | Yin 259 | Ying 260 | Yuan 261 | Yue 262 | Yun 263 | Zha 264 | Zhai 265 | Zhang 266 | Zhi 267 | Zhuan 268 | Zhui 269 | -------------------------------------------------------------------------------- /data/names/Czech.txt: -------------------------------------------------------------------------------- 1 | Abl 2 | Adsit 3 | Ajdrna 4 | Alt 5 | Antonowitsch 6 | Antonowitz 7 | Bacon 8 | Ballalatak 9 | Ballaltick 10 | Bartonova 11 | Bastl 12 | Baroch 13 | Benesch 14 | Betlach 15 | Biganska 16 | Bilek 17 | Blahut 18 | Blazek 19 | Blazek 20 | Blazejovsky 21 | Blecha 22 | Bleskan 23 | Blober 24 | Bock 25 | Bohac 26 | Bohunovsky 27 | Bolcar 28 | Borovka 29 | Borovski 30 | Borowski 31 | Borovsky 32 | Brabbery 33 | Brezovjak 34 | Brousil 35 | Bruckner 36 | Buchta 37 | Cablikova 38 | Camfrlova 39 | Cap 40 | Cerda 41 | Cermak 42 | Chermak 43 | Cermak 44 | Cernochova 45 | Cernohous 46 | Cerny 47 | Cerney 48 | Cerny 49 | Cerv 50 | Cervenka 51 | Chalupka 52 | Charlott 53 | Chemlik 54 | Chicken 55 | Chilar 56 | Chromy 57 | Cihak 58 | Clineburg 59 | Klineberg 60 | Cober 61 | Colling 62 | Cvacek 63 | Czabal 64 | Damell 65 | Demall 66 | Dehmel 67 | Dana 68 | Dejmal 69 | Dempko 70 | Demko 71 | Dinko 72 | Divoky 73 | Dolejsi 74 | Dolezal 75 | Doljs 76 | Dopita 77 | Drassal 78 | Driml 79 | Duyava 80 | Dvorak 81 | Dziadik 82 | Egr 83 | Entler 84 | Faltysek 85 | Faltejsek 86 | Fencl 87 | Fenyo 88 | Fillipova 89 | Finfera 90 | Finferovy 91 | Finke 92 | Fojtikova 93 | Fremut 94 | Friedrich 95 | Frierdich 96 | Fritsch 97 | Furtsch 98 | Gabrisova 99 | Gavalok 100 | Geier 101 | Georgijev 102 | Geryk 103 | Giersig 104 | Glatter 105 | Glockl 106 | Grabski 107 | Grozmanova 108 | Grulich 109 | Grygarova 110 | Hadash 111 | Hafernik 112 | Hajek 113 | Hajicek 114 | Hajkova 115 | Hana 116 | Hanek 117 | Hanek 118 | Hanika 119 | Hanusch 120 | Hanzlick 121 | Handzlik 122 | Hanzlik 123 | Harger 124 | Hartl 125 | Havlatova 126 | Havlice 127 | Hawlata 128 | Heidl 129 | Herback 130 | Herodes 131 | Hiorvst 132 | Hladky 133 | Hlavsa 134 | Hnizdil 135 | Hodowal 136 | Hodoval 137 | Holan 138 | Holub 139 | Homulka 140 | Hora 141 | Hovanec 142 | Hrabak 143 | Hradek 144 | Hrdy 145 | Hrula 146 | Hruska 147 | Hruskova 148 | Hudecek 149 | Husk 150 | Hynna 151 | Jaluvka 152 | Janca 153 | Janicek 154 | Jenicek 155 | Janacek 156 | Janick 157 | Janoch 158 | Janosik 159 | Janutka 160 | Jares 161 | Jarzembowski 162 | Jedlicka 163 | Jelinek 164 | Jindra 165 | Jirava 166 | Jirik 167 | Jirku 168 | Jirovy 169 | Jobst 170 | Jonas 171 | Kacirek 172 | Kafka 173 | Kafka 174 | Kaiser 175 | Kanak 176 | Kaplanek 177 | Kara 178 | Karlovsky 179 | Kasa 180 | Kasimor 181 | Kazimor 182 | Kazmier 183 | Katschker 184 | Kauphsman 185 | Kenzel 186 | Kerner 187 | Kesl 188 | Kessel 189 | Kessler 190 | Khork 191 | Kirchma 192 | Klein 193 | Klemper 194 | Klimes 195 | Kober 196 | Koberna 197 | Koci 198 | Kocian 199 | Kocian 200 | Kofron 201 | Kolacny 202 | Koliha 203 | Kolman 204 | Koma 205 | Komo 206 | Coma 207 | Konarik 208 | Kopp 209 | Kopecky 210 | Korandak 211 | Korycan 212 | Korycansky 213 | Kosko 214 | Kouba 215 | Kouba 216 | Koukal 217 | Koza 218 | Kozumplikova 219 | Kratschmar 220 | Krawiec 221 | Kreisinger 222 | Kremlacek 223 | Kremlicka 224 | Kreutschmer 225 | Krhovsky 226 | Krivan 227 | Krivolavy 228 | Kriz 229 | Kruessel 230 | Krupala 231 | Krytinar 232 | Kubin 233 | Kucera 234 | Kucharova 235 | Kudrna 236 | Kuffel 237 | Kupfel 238 | Kofel 239 | Kulhanek 240 | Kunik 241 | Kurtz 242 | Kusak 243 | Kvasnicka 244 | Lawa 245 | Linart 246 | Lind 247 | Lokay 248 | Loskot 249 | Ludwig 250 | Lynsmeier 251 | Macha 252 | Machacek 253 | Macikova 254 | Malafa 255 | Malec 256 | Malecha 257 | Maly 258 | Marek 259 | Marik 260 | Marik 261 | Markytan 262 | Matejka 263 | Matjeka 264 | Matocha 265 | Maxa/B 266 | Mayer 267 | Meier 268 | Merta 269 | Meszes 270 | Metjeka 271 | Michalovic 272 | Michalovicova 273 | Miksatkova 274 | Mojzis 275 | Mojjis 276 | Mozzis 277 | Molcan 278 | Monfort 279 | MonkoAustria 280 | Morava 281 | Morek 282 | Muchalon 283 | Mudra 284 | Muhlbauer 285 | Nadvornizch 286 | Nadwornik 287 | Navara 288 | Navratil 289 | Navratil 290 | Navrkal 291 | Nekuza 292 | Nemec 293 | Nemecek 294 | Nestrojil 295 | Netsch 296 | Neusser 297 | Neisser 298 | Naizer 299 | Novak 300 | Nowak 301 | Novotny 302 | Novy Novy 303 | Oborny 304 | Ocasek 305 | Ocaskova 306 | Oesterreicher 307 | Okenfuss 308 | Olbrich 309 | Ondrisek 310 | Opizka 311 | Opova 312 | Opp 313 | Osladil 314 | Ozimuk 315 | Pachr 316 | Palzewicz 317 | Panek 318 | Patril 319 | Pavlik 320 | Pavlicka 321 | Pavlu 322 | Pawlak 323 | Pear 324 | Peary 325 | Pech 326 | Peisar 327 | Paisar 328 | Paiser 329 | Perevuznik 330 | Perina 331 | Persein 332 | Petrezelka 333 | Petru 334 | Pesek 335 | Petersen 336 | Pfeifer 337 | Picha 338 | Pillar 339 | Pellar 340 | Piller 341 | Pinter 342 | Pitterman 343 | Planick 344 | Piskach 345 | Plisek 346 | Plisko 347 | Pokorny 348 | Ponec 349 | Ponec 350 | Prachar 351 | Praseta 352 | Prchal 353 | Prehatney 354 | Pretsch 355 | Prill 356 | Psik 357 | Pudel 358 | Purdes 359 | Quasninsky 360 | Raffel 361 | Rafaj 362 | Ransom 363 | Rezac 364 | Riedel 365 | Riha 366 | Riha 367 | Ritchie 368 | Rozinek 369 | Ruba 370 | Ruda 371 | Rumisek 372 | Ruzicka 373 | Rypka 374 | Rebka 375 | Rzehak 376 | Sabol 377 | Safko 378 | Samz 379 | Sankovsky 380 | Sappe 381 | Sappe 382 | Sarna 383 | Satorie 384 | Savchak 385 | Svotak 386 | Swatchak 387 | Svocak 388 | Svotchak 389 | Schallom 390 | Schenk 391 | Schlantz 392 | Schmeiser 393 | Schneider 394 | Schmied 395 | Schubert 396 | Schwarz 397 | Schwartz 398 | Sedmik 399 | Sedmikova 400 | Seger 401 | Sekovora 402 | Semick 403 | Serak 404 | Sherak 405 | Shima 406 | Shula 407 | Siegl 408 | Silhan 409 | Simecek 410 | Simodines 411 | Simonek 412 | Sip 413 | Sitta 414 | Skala 415 | Skeril 416 | Skokan 417 | Skomicka 418 | Skwor 419 | Slapnickova 420 | Slejtr 421 | Slepicka 422 | Slepica 423 | Slezak 424 | Slivka 425 | Smith 426 | Snelker 427 | Sokolik 428 | Soucek 429 | Soukup 430 | Soukup 431 | Spicka 432 | Spoerl 433 | Sponer 434 | Srda 435 | Srpcikova 436 | Stangl 437 | Stanzel 438 | Stary 439 | Staska 440 | Stedronsky 441 | Stegon 442 | Sztegon 443 | Steinborn 444 | Stepan 445 | Stites 446 | Stluka 447 | Stotzky 448 | StrakaO 449 | Stramba 450 | Stupka 451 | Subertova 452 | Suchanka 453 | Sula 454 | Svejda 455 | Svejkovsky 456 | Svoboda 457 | Tejc 458 | Tikal 459 | Tykal 460 | Till 461 | Timpe 462 | Timpy 463 | Toman 464 | Tomanek 465 | Tomasek 466 | Tomes 467 | Trampotova 468 | Trampota 469 | Treblik 470 | Trnkova 471 | Uerling 472 | Uhlik 473 | Urbanek 474 | Urbanek 475 | Urbanovska 476 | Urista 477 | Ustohal 478 | Vaca 479 | Vaculova 480 | Vavra 481 | Vejvoda 482 | Veverka 483 | Victor 484 | Vlach 485 | Vlach 486 | Vlasak 487 | Vlasek 488 | Volcik 489 | Voneve 490 | Votke 491 | Vozab 492 | Vrazel 493 | Vykruta 494 | Wykruta 495 | Waclauska 496 | Weichert 497 | Weineltk 498 | Weisener 499 | Wiesner 500 | Wizner 501 | Weiss 502 | Werlla 503 | Whitmire 504 | Widerlechner 505 | Wilchek 506 | Wondracek 507 | Wood 508 | Zajicek 509 | Zak 510 | Zajicek 511 | Zaruba 512 | Zaruba 513 | Zelinka 514 | Zeman 515 | Zimola 516 | Zipperer 517 | Zitka 518 | Zoucha 519 | Zwolenksy 520 | -------------------------------------------------------------------------------- /data/names/Dutch.txt: -------------------------------------------------------------------------------- 1 | Aalsburg 2 | Aalst 3 | Aarle 4 | Achteren 5 | Achthoven 6 | Adrichem 7 | Aggelen 8 | Agteren 9 | Agthoven 10 | Akkeren 11 | Aller 12 | Alphen 13 | Alst 14 | Altena 15 | Althuis 16 | Amelsvoort 17 | Amersvoort 18 | Amstel 19 | Andel 20 | Andringa 21 | Ankeren 22 | Antwerp 23 | Antwerpen 24 | Apeldoorn 25 | Arendonk 26 | Asch 27 | Assen 28 | Baarle 29 | Bokhoven 30 | Breda 31 | Bueren 32 | Buggenum 33 | Buiren 34 | Buren 35 | Can 36 | Cann 37 | Canne 38 | Daal 39 | Daalen 40 | Dael 41 | Daele 42 | Dale 43 | Dalen 44 | Laar 45 | Vliert 46 | Akker 47 | Andel 48 | Denend 49 | Aart 50 | Beek 51 | Berg 52 | Hout 53 | Laar 54 | See 55 | Stoep 56 | Veen 57 | Ven 58 | Venn 59 | Venne 60 | Vennen 61 | Zee 62 | Donk 63 | Haanraads 64 | Haanraats 65 | Haanrade 66 | Haanrath 67 | Haenraats 68 | Haenraets 69 | Hanraets 70 | Hassel 71 | Hautem 72 | Hautum 73 | Heel 74 | Herten 75 | Hofwegen 76 | Horn 77 | Hout 78 | Houte 79 | Houtem 80 | Houten 81 | Houttum 82 | Houtum 83 | Kan 84 | Kann 85 | Kanne 86 | Kappel 87 | Karl 88 | Kikkert 89 | Klein 90 | Klerk 91 | Klerken 92 | Klerks 93 | Klerkse 94 | Klerkx 95 | Klerx 96 | Kloet 97 | Kloeten 98 | Kloeter 99 | Koeman 100 | Koemans 101 | Kolen 102 | Kolijn 103 | Kollen 104 | Koning 105 | Kool 106 | Koole 107 | Koolen 108 | Kools 109 | Kouman 110 | Koumans 111 | Krantz 112 | Kranz 113 | Krusen 114 | Kuijpers 115 | Kuiper 116 | Kuipers 117 | Laar 118 | Langbroek 119 | Laren 120 | Lauwens 121 | Lauwers 122 | Leeuwenhoeck 123 | Leeuwenhoek 124 | Leeuwenhoek 125 | Lucas 126 | Lucassen 127 | Lyon 128 | Maas 129 | Maes 130 | Maessen 131 | Marquering 132 | Marqueringh 133 | Marquerink 134 | Mas 135 | Meeuwe 136 | Meeuwes 137 | Meeuwessen 138 | Meeuweszen 139 | Meeuwis 140 | Meeuwissen 141 | Meeuwsen 142 | Meisner 143 | Merckx 144 | Mertens 145 | Michel 146 | Middelburg 147 | Middlesworth 148 | Mohren 149 | Mooren 150 | Mulder 151 | Muyskens 152 | Nagel 153 | Nelissen 154 | Nifterick 155 | Nifterick 156 | Nifterik 157 | Nifterik 158 | Niftrik 159 | Niftrik 160 | Offermans 161 | Ogterop 162 | Ogtrop 163 | Oirschot 164 | Oirschotten 165 | Oomen 166 | Oorschot 167 | Oorschot 168 | Ophoven 169 | Otten 170 | Pander 171 | Panders 172 | Paulis 173 | Paulissen 174 | Peerenboom 175 | Peeters 176 | Peij 177 | Pender 178 | Penders 179 | Pennders 180 | Penner 181 | Penners 182 | Peter 183 | Peusen 184 | Pey 185 | Philips 186 | Prinsen 187 | Rademaker 188 | Rademakers 189 | Ramaaker 190 | Ramaker 191 | Ramakers 192 | Ramecker 193 | Rameckers 194 | Raske 195 | Reijnder 196 | Reijnders 197 | Reinder 198 | Reinders 199 | Reynder 200 | Reynders 201 | Richard 202 | Rietveld 203 | Rijnder 204 | Rijnders 205 | Robert 206 | Roggeveen 207 | Roijacker 208 | Roijackers 209 | Roijakker 210 | Roijakkers 211 | Romeijn 212 | Romeijnders 213 | Romeijnsen 214 | Romijn 215 | Romijnders 216 | Romijnsen 217 | Rompa 218 | Rompa 219 | Rompaeij 220 | Rompaey 221 | Rompaij 222 | Rompay 223 | Rompaye 224 | Rompu 225 | Rompuy 226 | Rooiakker 227 | Rooiakkers 228 | Rooijakker 229 | Rooijakkers 230 | Roosa 231 | Roosevelt 232 | Rossem 233 | Rossum 234 | Rumpade 235 | Rutten 236 | Ryskamp 237 | Samson 238 | Sanna 239 | Schenck 240 | Schermer 241 | Schneider 242 | Schneiders 243 | Schneijder 244 | Schneijders 245 | Schoonenburg 246 | Schoonraad 247 | Schoorel 248 | Schoorel 249 | Schoorl 250 | Schorel 251 | Schrijnemakers 252 | Schuyler 253 | Schwarzenberg 254 | Seeger 255 | Seegers 256 | Seelen 257 | Segers 258 | Segher 259 | Seghers 260 | Severijns 261 | Severins 262 | Sevriens 263 | Silje 264 | Simon 265 | Simonis 266 | Slootmaekers 267 | Smeets 268 | Smets 269 | Smit 270 | Smits 271 | Snaaijer 272 | Snaijer 273 | Sneiders 274 | Sneijder 275 | Sneijders 276 | Sneijer 277 | Sneijers 278 | Snell 279 | Snider 280 | Sniders 281 | Snijder 282 | Snijders 283 | Snyder 284 | Snyders 285 | Specht 286 | Spijker 287 | Spiker 288 | Ter Avest 289 | Teunissen 290 | Theunissen 291 | Tholberg 292 | Tillens 293 | Tunison 294 | Tunneson 295 | Vandale 296 | Vandroogenbroeck 297 | Vann 298 | -------------------------------------------------------------------------------- /data/names/French.txt: -------------------------------------------------------------------------------- 1 | Abel 2 | Abraham 3 | Adam 4 | Albert 5 | Allard 6 | Archambault 7 | Armistead 8 | Arthur 9 | Augustin 10 | Babineaux 11 | Baudin 12 | Beauchene 13 | Beaulieu 14 | Beaumont 15 | Bélanger 16 | Bellamy 17 | Bellerose 18 | Belrose 19 | Berger 20 | Béringer 21 | Bernard 22 | Bertrand 23 | Bisset 24 | Bissette 25 | Blaise 26 | Blanc 27 | Blanchet 28 | Blanchett 29 | Bonfils 30 | Bonheur 31 | Bonhomme 32 | Bonnaire 33 | Bonnay 34 | Bonner 35 | Bonnet 36 | Borde 37 | Bordelon 38 | Bouchard 39 | Boucher 40 | Brisbois 41 | Brodeur 42 | Bureau 43 | Caron 44 | Cavey 45 | Chaput 46 | Charbonneau 47 | Charpentier 48 | Charron 49 | Chastain 50 | Chevalier 51 | Chevrolet 52 | Cloutier 53 | Colbert 54 | Comtois 55 | Cornett 56 | Coté 57 | Coupe 58 | Courtemanche 59 | Cousineau 60 | Couture 61 | Daniau 62 | D'aramitz 63 | Daviau 64 | David 65 | Deforest 66 | Degarmo 67 | Delacroix 68 | De la fontaine 69 | Deniau 70 | Deniaud 71 | Deniel 72 | Denis 73 | De sauveterre 74 | Deschamps 75 | Descoteaux 76 | Desjardins 77 | Desrochers 78 | Desrosiers 79 | Dubois 80 | Duchamps 81 | Dufort 82 | Dufour 83 | Duguay 84 | Dupond 85 | Dupont 86 | Durand 87 | Durant 88 | Duval 89 | Émile 90 | Eustis 91 | Fabian 92 | Fabre 93 | Fabron 94 | Faucher 95 | Faucheux 96 | Faure 97 | Favager 98 | Favre 99 | Favreau 100 | Fay 101 | Félix 102 | Firmin 103 | Fontaine 104 | Forest 105 | Forestier 106 | Fortier 107 | Foss 108 | Fournier 109 | Gage 110 | Gagne 111 | Gagnier 112 | Gagnon 113 | Garcon 114 | Gardinier 115 | Germain 116 | Géroux 117 | Giles 118 | Girard 119 | Giroux 120 | Glaisyer 121 | Gosse 122 | Gosselin 123 | Granger 124 | Guérin 125 | Guillory 126 | Hardy 127 | Harman 128 | Hébert 129 | Herbert 130 | Herriot 131 | Jacques 132 | Janvier 133 | Jordan 134 | Joubert 135 | Labelle 136 | Lachance 137 | Lachapelle 138 | Lamar 139 | Lambert 140 | Lane 141 | Langlais 142 | Langlois 143 | Lapointe 144 | Larue 145 | Laurent 146 | Lavigne 147 | Lavoie 148 | Leandres 149 | Lebeau 150 | Leblanc 151 | Leclair 152 | Leclerc 153 | Lécuyer 154 | Lefebvre 155 | Lefévre 156 | Lefurgey 157 | Legrand 158 | Lemaire 159 | Lémieux 160 | Leon 161 | Leroy 162 | Lesauvage 163 | Lestrange 164 | Lévêque 165 | Lévesque 166 | Linville 167 | Lyon 168 | Lyon 169 | Maçon 170 | Marchand 171 | Marie 172 | Marion 173 | Martel 174 | Martel 175 | Martin 176 | Masson 177 | Masson 178 | Mathieu 179 | Mercier 180 | Merle 181 | Michaud 182 | Michel 183 | Monet 184 | Monette 185 | Montagne 186 | Moreau 187 | Moulin 188 | Mullins 189 | Noel 190 | Oliver 191 | Olivier 192 | Page 193 | Paget 194 | Palomer 195 | Pan 196 | Pape 197 | Paquet 198 | Paquet 199 | Parent 200 | Paris 201 | Parris 202 | Pascal 203 | Patenaude 204 | Paternoster 205 | Paul 206 | Pelletier 207 | Perrault 208 | Perreault 209 | Perrot 210 | Petit 211 | Pettigrew 212 | Pierre 213 | Plamondon 214 | Plourde 215 | Poingdestre 216 | Poirier 217 | Porcher 218 | Poulin 219 | Proulx 220 | Renaud 221 | Rey 222 | Reyer 223 | Richard 224 | Richelieu 225 | Robert 226 | Roche 227 | Rome 228 | Romilly 229 | Rose 230 | Rousseau 231 | Roux 232 | Roy 233 | Royer 234 | Salomon 235 | Salvage 236 | Samson 237 | Samuel 238 | Sargent 239 | Sarkozi 240 | Sarkozy 241 | Sartre 242 | Sault 243 | Sauvage 244 | Sauvageau 245 | Sauvageon 246 | Sauvageot 247 | Sauveterre 248 | Savatier 249 | Segal 250 | Sergeant 251 | Séverin 252 | Simon 253 | Solomon 254 | Soucy 255 | St martin 256 | St pierre 257 | Tailler 258 | Tasse 259 | Thayer 260 | Thibault 261 | Thomas 262 | Tobias 263 | Tolbert 264 | Traver 265 | Travere 266 | Travers 267 | Traverse 268 | Travert 269 | Tremblay 270 | Tremble 271 | Victor 272 | Victors 273 | Villeneuve 274 | Vincent 275 | Vipond 276 | Voclain 277 | Yount 278 | -------------------------------------------------------------------------------- /data/names/German.txt: -------------------------------------------------------------------------------- 1 | Abbing 2 | Abel 3 | Abeln 4 | Abt 5 | Achilles 6 | Achterberg 7 | Acker 8 | Ackermann 9 | Adam 10 | Adenauer 11 | Adler 12 | Adlersflügel 13 | Aeschelman 14 | Albert 15 | Albrecht 16 | Aleshire 17 | Aleshite 18 | Althaus 19 | Amsel 20 | Andres 21 | Armbrüster 22 | Armbruster 23 | Artz 24 | Aue 25 | Auer 26 | Augustin 27 | Aust 28 | Autenburg 29 | Auttenberg 30 | Baasch 31 | Bach 32 | Bachmeier 33 | Bäcker 34 | Bader 35 | Bähr 36 | Bambach 37 | Bauer 38 | Bauers 39 | Baum 40 | Baumann 41 | Baumbach 42 | Baumgärtner 43 | Baumgartner 44 | Baumhauer 45 | Bayer 46 | Beck 47 | Becke 48 | Beckenbauer 49 | Becker 50 | Beckert 51 | Behrend 52 | Behrends 53 | Beitel 54 | Beltz 55 | Benn 56 | Berg 57 | Berger 58 | Bergfalk 59 | Beringer 60 | Bernat 61 | Best 62 | Beutel 63 | Beyer 64 | Beyersdorf 65 | Bieber 66 | Biermann 67 | Bischoffs 68 | Blau 69 | Blecher 70 | Bleier 71 | Blumenthal 72 | Blumstein 73 | Bocker 74 | Boehler 75 | Boer 76 | Boesch 77 | Böhler 78 | Böhm 79 | Böhme 80 | Böhmer 81 | Bohn 82 | Borchard 83 | Bösch 84 | Bosch 85 | Böttcher 86 | Brahms 87 | Brand 88 | Brandt 89 | Brant 90 | Brauer 91 | Braun 92 | Braune 93 | Breiner 94 | Breisacher 95 | Breitbarth 96 | Bretz 97 | Brinkerhoff 98 | Brodbeck 99 | Brose 100 | Brotz 101 | Bruhn 102 | Brun 103 | Brune 104 | Buchholz 105 | Buckholtz 106 | Buhr 107 | Bumgarner 108 | Burgstaller 109 | Busch 110 | Carver 111 | Chevrolet 112 | Cline 113 | Dahl 114 | Denzel 115 | Derrick 116 | Diefenbach 117 | Dieter 118 | Dietrich 119 | Dirchs 120 | Dittmar 121 | Dohman 122 | Drechsler 123 | Dreher 124 | Dreschner 125 | Dresdner 126 | Dressler 127 | Duerr 128 | Dunkle 129 | Dunst 130 | Dürr 131 | Eberhardt 132 | Ebner 133 | Ebner 134 | Eckstein 135 | Egger 136 | Eichel 137 | Eilerts 138 | Engel 139 | Enns 140 | Esser 141 | Essert 142 | Everhart 143 | Fabel 144 | Faerber 145 | Falk 146 | Falkenrath 147 | Färber 148 | Fashingbauer 149 | Faust 150 | Feigenbaum 151 | Feld 152 | Feldt 153 | Fenstermacher 154 | Fertig 155 | Fiedler 156 | Fischer 157 | Flater 158 | Fleischer 159 | Foerstner 160 | Forst 161 | Förstner 162 | Foth 163 | Frank 164 | Franke 165 | Frei 166 | Freud 167 | Freudenberger 168 | Freund 169 | Fried 170 | Friedrich 171 | Fromm 172 | Frost 173 | Fuchs 174 | Fuhrmann 175 | Fürst 176 | Fux 177 | Gabler 178 | Gaertner 179 | Garb 180 | Garber 181 | Gärtner 182 | Garver 183 | Gass 184 | Gehrig 185 | Gehring 186 | Geier 187 | Geiger 188 | Geisler 189 | Geissler 190 | Geiszler 191 | Gensch 192 | Gerber 193 | Gerhard 194 | Gerhardt 195 | Gerig 196 | Gerst 197 | Gerstle 198 | Gerver 199 | Giehl 200 | Giese 201 | Glöckner 202 | Goebel 203 | Goldschmidt 204 | Gorman 205 | Gott 206 | Gotti 207 | Gottlieb 208 | Gottschalk 209 | Graner 210 | Greenberg 211 | Groos 212 | Gros 213 | Gross 214 | Groß 215 | Große 216 | Grosse 217 | Größel 218 | Großel 219 | Großer 220 | Grosser 221 | Grosz 222 | Grünewald 223 | Günther 224 | Gunther 225 | Gutermuth 226 | Gwerder 227 | Haas 228 | Haase 229 | Haber 230 | Habich 231 | Habicht 232 | Hafner 233 | Hahn 234 | Hall 235 | Halle 236 | Harman 237 | Hartmann 238 | Hase 239 | Hasek 240 | Hasenkamp 241 | Hass 242 | Hauer 243 | Haupt 244 | Hausler 245 | Havener 246 | Heidrich 247 | Heinrich 248 | Heinrichs 249 | Heintze 250 | Hellewege 251 | Heppenheimer 252 | Herbert 253 | Hermann 254 | Herrmann 255 | Herschel 256 | Hertz 257 | Hildebrand 258 | Hinrichs 259 | Hintzen 260 | Hirsch 261 | Hoch 262 | Hochberg 263 | Hoefler 264 | Hofer 265 | Hoffman 266 | Hoffmann 267 | Höfler 268 | Hofmann 269 | Hofmeister 270 | Holst 271 | Holtzer 272 | Hölzer 273 | Holzer 274 | Holzknecht 275 | Holzmann 276 | Hoover 277 | Horn 278 | Horn 279 | Horowitz 280 | Houk 281 | Hüber 282 | Huber 283 | Huff 284 | Huffman 285 | Huffmann 286 | Hummel 287 | Hummel 288 | Hutmacher 289 | Ingersleben 290 | Jaeger 291 | Jäger 292 | Jager 293 | Jans 294 | Janson 295 | Janz 296 | Jollenbeck 297 | Jordan 298 | Jund 299 | Jung 300 | Junge 301 | Kahler 302 | Kaiser 303 | Kalb 304 | Kalbfleisch 305 | Kappel 306 | Karl 307 | Kaspar 308 | Kassmeyer 309 | Kästner 310 | Katz 311 | Kaube 312 | Käufer 313 | Kaufer 314 | Kauffmann 315 | Kaufman 316 | Keil 317 | Keller 318 | Kempf 319 | Kerner 320 | Kerper 321 | Kerwar 322 | Kerwer 323 | Kiefer 324 | Kiefer 325 | Kirchner 326 | Kistler 327 | Kistner 328 | Kleid 329 | Klein 330 | Klossner 331 | Knef 332 | Kneib 333 | Kneller 334 | Knepp 335 | Knochenmus 336 | Knopf 337 | Knopp 338 | Koch 339 | Kock 340 | Koenig 341 | Koenigsmann 342 | Köhl 343 | Kohl 344 | Köhler 345 | Kohler 346 | Kolbe 347 | König 348 | Königsmann 349 | Kopp 350 | Kraemer 351 | Krämer 352 | Kramer 353 | Krantz 354 | Kranz 355 | Kraus 356 | Krause 357 | Krauss 358 | Krauß 359 | Krebs 360 | Kröger 361 | Kron 362 | Kruckel 363 | Krüger 364 | Krüger 365 | Kruger 366 | Kruse 367 | Kruse 368 | Küchler 369 | Kuhn 370 | Kundert 371 | Kunkel 372 | Kunkle 373 | Kuntz 374 | Kunze 375 | Kurzmann 376 | Laberenz 377 | Lafrentz 378 | Lafrenz 379 | Landau 380 | Lang 381 | Lange 382 | Langenberg 383 | Langer 384 | Larenz 385 | Laurenz 386 | Lauritz 387 | Lawerenz 388 | Lawrenz 389 | Lehmann 390 | Lehrer 391 | Leitner 392 | Leitz 393 | Leitzke 394 | Lenz 395 | Leverenz 396 | Lewerentz 397 | Lewerenz 398 | Lichtenberg 399 | Lieberenz 400 | Linden 401 | Loewe 402 | Lohrenz 403 | Lorentz 404 | Lorenz 405 | Lorenzen 406 | Loris 407 | Loritz 408 | Löwe 409 | Ludwig 410 | Luther 411 | Maas 412 | Maier 413 | Mandel 414 | Mann 415 | Markwardt 416 | Marquardt 417 | Marquering 418 | Marquerink 419 | Martell 420 | Martin 421 | Martz 422 | Mas 423 | Maurer 424 | Maus 425 | Mayer 426 | Meier 427 | Mein 428 | Meindl 429 | Meinhardt 430 | Meisner 431 | Meissner 432 | Melsbach 433 | Mendel 434 | Mendelsohn 435 | Mendelssohn 436 | Messer 437 | Messerli 438 | Messmann 439 | Messner 440 | Metz 441 | Metz 442 | Metzger 443 | Meyer 444 | Michel 445 | Mohren 446 | Möller 447 | Morgenstern 448 | Moser 449 | Mueller 450 | Muhlfeld 451 | Müller 452 | Nagel 453 | Neuman 454 | Neumann 455 | Nuremberg 456 | Nussbaum 457 | Nussenbaum 458 | Oberst 459 | Oelberg 460 | Ohme 461 | Oliver 462 | Oppenheimer 463 | Ott 464 | Otto 465 | Oursler 466 | Pahlke 467 | Papke 468 | Papp 469 | Paternoster 470 | Paul 471 | Paulis 472 | Pawlitzki 473 | Penzig 474 | Peter 475 | Peters 476 | Pfaff 477 | Pfenning 478 | Plank 479 | Pletcher 480 | Porsche 481 | Portner 482 | Prinz 483 | Protz 484 | Rademacher 485 | Rademaker 486 | Rapp 487 | Raske 488 | Raskob 489 | Raskop 490 | Raskoph 491 | Regenbogen 492 | Reier 493 | Reiher 494 | Reiter 495 | Rettig 496 | Reuter 497 | Reuter 498 | Richard 499 | Richter 500 | Rier 501 | Riese 502 | Ritter 503 | Rose 504 | Rosenberg 505 | Rosenberger 506 | Rosenfeld 507 | Rot 508 | Roth 509 | Rothbauer 510 | Rothenberg 511 | Rothschild 512 | Sachs 513 | Saller 514 | Saller 515 | Salomon 516 | Salzwedel 517 | Samuel 518 | Sander 519 | Sauber 520 | Schäfer 521 | Scheer 522 | Scheinberg 523 | Schenck 524 | Schermer 525 | Schindler 526 | Schirmer 527 | Schlender 528 | Schlimme 529 | Schlusser 530 | Schmeling 531 | Schmid 532 | Schmidt 533 | Schmitt 534 | Schmitz 535 | Schneider 536 | Schnoor 537 | Schnur 538 | Schoettmer 539 | Schräder 540 | Schrader 541 | Schreck 542 | Schreier 543 | Schröder 544 | Schröder 545 | Schroeder 546 | Schroeter 547 | Schröter 548 | Schubert 549 | Schuchard 550 | Schuchardt 551 | Schuchert 552 | Schuhart 553 | Schuhmacher 554 | Schuler 555 | Schult 556 | Schulte 557 | Schultes 558 | Schultheis 559 | Schultheiss 560 | Schultheiß 561 | Schultz 562 | Schultze 563 | Schulz 564 | Schulze 565 | Schumacher 566 | Schuster 567 | Schuttmann 568 | Schwangau 569 | Schwartz 570 | Schwarz 571 | Schwarzenegger 572 | Schwenke 573 | Schwinghammer 574 | Seelenfreund 575 | Seidel 576 | Senft 577 | Senft 578 | Sheinfeld 579 | Shriver 580 | Siegel 581 | Siegel 582 | Siekert 583 | Siemon 584 | Silverstein 585 | Simen 586 | Simmon 587 | Simon 588 | Simons 589 | Siskin 590 | Siskind 591 | Sitz 592 | Sitz 593 | Slusser 594 | Solberg 595 | Sommer 596 | Sommer 597 | Sommer 598 | Sommer 599 | Sonnen 600 | Sorg 601 | Sorge 602 | Spannagel 603 | Specht 604 | Spellmeyer 605 | Spitznogle 606 | Sponaugle 607 | Stark 608 | Stauss 609 | Steen 610 | Steffen 611 | Stein 612 | Steinmann 613 | Stenger 614 | Sternberg 615 | Steube 616 | Steuben 617 | Stieber 618 | Stoppelbein 619 | Stoppelbein 620 | Strand 621 | Straub 622 | Strobel 623 | Strohkirch 624 | Stroman 625 | Stuber 626 | Stueck 627 | Stumpf 628 | Sturm 629 | Suess 630 | Sulzbach 631 | Swango 632 | Switzer 633 | Tangeman 634 | Tanzer 635 | Teufel 636 | Tiedeman 637 | Tifft 638 | Tillens 639 | Tobias 640 | Tolkien 641 | Tresler 642 | Tritten 643 | Trumbauer 644 | Tschida 645 | Unkle 646 | Unruh 647 | Unterbrink 648 | Ursler 649 | Vann 650 | Van tonder 651 | Vieth 652 | Vogel 653 | Vogt 654 | Vogts 655 | Voigt 656 | Voigts 657 | Volk 658 | Voll 659 | Von brandt 660 | Von essen 661 | Von grimmelshausen 662 | Von ingersleben 663 | Vonnegut 664 | Von wegberg 665 | Voss 666 | Voß 667 | Wägner 668 | Wagner 669 | Wähner 670 | Wahner 671 | Waldfogel 672 | Waldvogel 673 | Walkenhorst 674 | Walter 675 | Walther 676 | Waltz 677 | Wang 678 | Warner 679 | Waxweiler 680 | Weber 681 | Wechsler 682 | Wedekind 683 | Weeber 684 | Wegener 685 | Wegner 686 | Wehner 687 | Wehunt 688 | Weigand 689 | Weiman 690 | Weiner 691 | Weiss 692 | Weiß 693 | Welter 694 | Wendel 695 | Wendell 696 | Werner 697 | Wernher 698 | West 699 | Westerberg 700 | Wetterman 701 | Wetzel 702 | Wexler 703 | Wieck 704 | Wiegand 705 | Wildgrube 706 | Winter 707 | Winther 708 | Winther 709 | Wirner 710 | Wirnhier 711 | Wirt 712 | Wirth 713 | Wolf 714 | Wolff 715 | Wolter 716 | Wörner 717 | Wörnhör 718 | Wruck 719 | Wyman 720 | Xylander 721 | Zellweger 722 | Zilberschlag 723 | Zimmerman 724 | Zimmermann 725 | -------------------------------------------------------------------------------- /data/names/Greek.txt: -------------------------------------------------------------------------------- 1 | Adamidis 2 | Adamou 3 | Agelakos 4 | Akrivopoulos 5 | Alexandropoulos 6 | Anetakis 7 | Angelopoulos 8 | Antimisiaris 9 | Antipas 10 | Antonakos 11 | Antoniadis 12 | Antonopoulos 13 | Antonopoulos 14 | Antonopoulos 15 | Arvanitoyannis 16 | Avgerinos 17 | Banos 18 | Batsakis 19 | Bekyros 20 | Belesis 21 | Bertsimas 22 | Bilias 23 | Blades 24 | Bouloukos 25 | Brisimitzakis 26 | Bursinos 27 | Calogerakis 28 | Calpis 29 | Chellos 30 | Christakos 31 | Christodoulou 32 | Christou 33 | Chrysanthopoulos 34 | Chrysanthopoulos 35 | Comino 36 | Close 37 | Close 38 | Close 39 | Close 40 | Close 41 | Close 42 | Close 43 | Close 44 | Dalianis 45 | Danas 46 | Dasios 47 | Demakis 48 | Demarchis 49 | Demas 50 | Demetrious 51 | Dertilis 52 | Diakogeorgiou 53 | Dioletis 54 | Dounias 55 | Dritsas 56 | Drivakis 57 | Eatros 58 | Egonidis 59 | Eliopoulos 60 | Forakis 61 | Fotopoulos 62 | Fourakis 63 | Frangopoulos 64 | Galanopoulos 65 | Garofalis 66 | Gavril 67 | Gavrilopoulos 68 | Georgeakopoulos 69 | Geracimos 70 | Gianakopulos 71 | Giannakopoulos 72 | Giannakos 73 | Glynatsis 74 | Gomatos 75 | Grammatakakis 76 | Gravari 77 | Hadjiyianakies 78 | Hagias 79 | Haritopoulos 80 | Honjas 81 | Horiatis 82 | Houlis 83 | Jamussa 84 | Kaglantge 85 | Kalakos 86 | Kalogeria 87 | Kaloxylos 88 | Kanavos 89 | Kapsimalles 90 | Karahalios 91 | Karameros 92 | Karkampasis 93 | Karnoupakis 94 | Katsourinis 95 | Kefalas 96 | Kokkali 97 | Kokoris 98 | Kolovos 99 | Konstantatos 100 | Kosmas 101 | Kotsilimbas 102 | Kotsiopoulos 103 | Kouches 104 | Koulaxizis 105 | Koumanidis 106 | Kourempes 107 | Kouretas 108 | Kouropoulos 109 | Kouros 110 | Koustoubos 111 | Koutsoubos 112 | Kreskas 113 | Kringos 114 | Kyritsis 115 | Laganas 116 | Leontarakis 117 | Letsos 118 | Liatos 119 | Lillis 120 | Lolos 121 | Louverdis 122 | Makricosta 123 | Malihoudis 124 | Maneates 125 | Manos 126 | Manoukarakis 127 | Matsoukis 128 | Mentis 129 | Mersinias 130 | Metrofanis 131 | Michalaras 132 | Milionis 133 | Missiakos 134 | Moraitopoulos 135 | Nikolaou 136 | Nomikos 137 | Paitakes 138 | Paloumbas 139 | Panayiotopoulos 140 | Panoulias 141 | Pantelakos 142 | Pantelas 143 | Papadelias 144 | Papadopulos 145 | Papageorge 146 | Papoutsis 147 | Pappayiorgas 148 | Paraskevopoulos 149 | Paraskos 150 | Paschalis 151 | Patrianakos 152 | Patselas 153 | Pefanis 154 | Petimezas 155 | Petrakis 156 | Pezos 157 | Phocas 158 | Pispinis 159 | Polites 160 | Polymenakou 161 | Poniros 162 | Protopsaltis 163 | Rallis 164 | Rigatos 165 | Rorris 166 | Rousses 167 | Ruvelas 168 | Sakelaris 169 | Sakellariou 170 | Samios 171 | Sardelis 172 | Sfakianos 173 | Sklavenitis 174 | Sortras 175 | Sotiris 176 | Spyridis 177 | Stamatas 178 | Stamatelos 179 | Stavropoulos 180 | Strilakos 181 | Stroggylis 182 | Tableriou 183 | Taflambas 184 | Tassioglou 185 | Telis 186 | Tsoumada 187 | Theofilopoulos 188 | Theohari 189 | Totolos 190 | Tourna 191 | Tsahalis 192 | Tsangaris 193 | Tselios 194 | Tsogas 195 | Vamvakidis 196 | Varvitsiotes 197 | Vassilikos 198 | Vassilopulos 199 | Vlahos 200 | Vourlis 201 | Xydis 202 | Zaloumi 203 | Zouvelekis 204 | -------------------------------------------------------------------------------- /data/names/Irish.txt: -------------------------------------------------------------------------------- 1 | Adam 2 | Ahearn 3 | Aodh 4 | Aodha 5 | Aonghuis 6 | Aonghus 7 | Bhrighde 8 | Bradach 9 | Bradan 10 | Braden 11 | Brady 12 | Bran 13 | Brannon 14 | Brian 15 | Callaghan 16 | Caomh 17 | Carey 18 | Casey 19 | Cassidy 20 | Cathain 21 | Cathan 22 | Cathasach 23 | Ceallach 24 | Ceallachan 25 | Cearbhall 26 | Cennetig 27 | Ciardha 28 | Clark 29 | Cleirich 30 | Cleirigh 31 | Cnaimhin 32 | Coghlan 33 | Coilean 34 | Collins 35 | Colman 36 | Conall 37 | Conchobhar 38 | Conn 39 | Connell 40 | Connolly 41 | Cormac 42 | Corraidhin 43 | Cuidightheach 44 | Curran 45 | Dúbhshlaine 46 | Dalach 47 | Daly 48 | Damhain 49 | Damhan 50 | Delaney 51 | Desmond 52 | Devin 53 | Diarmaid 54 | Doherty 55 | Domhnall 56 | Donnchadh 57 | Donndubhan 58 | Donnell 59 | Donoghue 60 | Donovan 61 | Doyle 62 | Dubhain 63 | Dubhan 64 | Duncan 65 | Eoghan 66 | Eoin 67 | Eoin 68 | Faolan 69 | Farrell 70 | Fearghal 71 | Fergus 72 | Finn 73 | Finnegan 74 | Fionn 75 | Flanagan 76 | Flann 77 | Flynn 78 | Gallchobhar 79 | Gerald 80 | Giolla 81 | Gorman 82 | Hayden 83 | Ivor 84 | John 85 | Kavanagh 86 | Keefe 87 | Kelly 88 | Kennedy 89 | Lennon 90 | Login 91 | Macclelland 92 | Macdermott 93 | Maceachthighearna 94 | Macfarland 95 | Macghabhann 96 | Maciomhair 97 | Macshuibhne 98 | Madaidhin 99 | Madden 100 | Maguire 101 | Mahoney 102 | Maille 103 | Malone 104 | Manus 105 | Maolmhuaidh 106 | Mathghamhain 107 | Maurice 108 | Mcguire 109 | Mckay 110 | Mclain 111 | Mcmahon 112 | Mcnab 113 | Mcneil 114 | Meadhra 115 | Michael 116 | Milligan 117 | Mochan 118 | Mohan 119 | Molloy 120 | Monahan 121 | Mooney 122 | Muirchertach 123 | Mullen 124 | Mulryan 125 | Murchadh 126 | Murphy 127 | Names 128 | Naoimhin 129 | Naomhan 130 | Neil 131 | Neville 132 | Nevin 133 | Niadh 134 | Niall 135 | Nolan 136 | Nuallan 137 | O'Boyle 138 | O'Brien 139 | O'Byrne 140 | O'Donnell 141 | O'Hannagain 142 | O'Hannigain 143 | O'Keefe 144 | O'Mooney 145 | O'Neal 146 | O'Boyle 147 | O'Bree 148 | O'Brian 149 | O'Brien 150 | O'Callaghann 151 | O'Connell 152 | O'Connor 153 | O'Dell 154 | O'Doherty 155 | O'Donnell 156 | O'Donoghue 157 | O'Dowd 158 | O'Driscoll 159 | O'Gorman 160 | O'Grady 161 | O'Hagan 162 | O'Halloran 163 | O'Hanlon 164 | O'Hara 165 | O'Hare 166 | O'Kane 167 | O'Keefe 168 | O'Keeffe 169 | O'Kelly 170 | O'Leary 171 | O'Loughlin 172 | O'Mahoney 173 | O'Mahony 174 | O'Malley 175 | O'Meara 176 | O'Neal 177 | O'Neill 178 | O'Reilly 179 | O'Rourke 180 | O'Ryan 181 | O'Shea 182 | O'Sullivan 183 | O'Toole 184 | Patrick 185 | Peatain 186 | Pharlain 187 | Power 188 | Quigley 189 | Quinn 190 | Quirke 191 | Raghailligh 192 | Reagan 193 | Register 194 | Reilly 195 | Reynold 196 | Rhys 197 | Riagain 198 | Riagan 199 | Riain 200 | Rian 201 | Rinn 202 | Roach 203 | Rodagh 204 | Rory 205 | Ruadh 206 | Ruadhain 207 | Ruadhan 208 | Ruaidh 209 | Samuel 210 | Scolaidhe 211 | Seaghdha 212 | Sechnall 213 | Seighin 214 | Shannon 215 | Sheehy 216 | Simon 217 | Sioda 218 | Sloan 219 | Sluaghadhan 220 | Suaird 221 | Sullivan 222 | Tadhg 223 | Tadhgan 224 | Taidhg 225 | Teagan 226 | Teague 227 | Tighearnach 228 | Tracey 229 | Treasach 230 | Whalen 231 | Whelan 232 | William 233 | -------------------------------------------------------------------------------- /data/names/Italian.txt: -------------------------------------------------------------------------------- 1 | Abandonato 2 | Abatangelo 3 | Abatantuono 4 | Abate 5 | Abategiovanni 6 | Abatescianni 7 | Abbà 8 | Abbadelli 9 | Abbascia 10 | Abbatangelo 11 | Abbatantuono 12 | Abbate 13 | Abbatelli 14 | Abbaticchio 15 | Abbiati 16 | Abbracciabene 17 | Abbracciabeni 18 | Abelli 19 | Abelló 20 | Abrami 21 | Abramo 22 | Acardi 23 | Accardi 24 | Accardo 25 | Acciai 26 | Acciaio 27 | Acciaioli 28 | Acconci 29 | Acconcio 30 | Accorsi 31 | Accorso 32 | Accosi 33 | Accursio 34 | Acerbi 35 | Acone 36 | Aconi 37 | Acqua 38 | Acquafredda 39 | Acquarone 40 | Acquati 41 | Adalardi 42 | Adami 43 | Adamo 44 | Adamoli 45 | Addario 46 | Adelardi 47 | Adessi 48 | Adimari 49 | Adriatico 50 | Affini 51 | Africani 52 | Africano 53 | Agani 54 | Aggi 55 | Aggio 56 | Agli 57 | Agnelli 58 | Agnellutti 59 | Agnusdei 60 | Agosti 61 | Agostini 62 | Agresta 63 | Agrioli 64 | Aiello 65 | Aiolfi 66 | Airaldi 67 | Airò 68 | Aita 69 | Ajello 70 | Alagona 71 | Alamanni 72 | Albanesi 73 | Albani 74 | Albano 75 | Alberghi 76 | Alberghini 77 | Alberici 78 | Alberighi 79 | Albero 80 | Albini 81 | Albricci 82 | Albrici 83 | Alcheri 84 | Aldebrandi 85 | Alderisi 86 | Alduino 87 | Alemagna 88 | Aleppo 89 | Alesci 90 | Alescio 91 | Alesi 92 | Alesini 93 | Alesio 94 | Alessandri 95 | Alessi 96 | Alfero 97 | Aliberti 98 | Alinari 99 | Aliprandi 100 | Allegri 101 | Allegro 102 | Alò 103 | Aloia 104 | Aloisi 105 | Altamura 106 | Altimari 107 | Altoviti 108 | Alunni 109 | Amadei 110 | Amadori 111 | Amalberti 112 | Amantea 113 | Amato 114 | Amatore 115 | Ambrogi 116 | Ambrosi 117 | Amello 118 | Amerighi 119 | Amoretto 120 | Angioli 121 | Ansaldi 122 | Anselmetti 123 | Anselmi 124 | Antonelli 125 | Antonini 126 | Antonino 127 | Aquila 128 | Aquino 129 | Arbore 130 | Ardiccioni 131 | Ardizzone 132 | Ardovini 133 | Arena 134 | Aringheri 135 | Arlotti 136 | Armani 137 | Armati 138 | Armonni 139 | Arnolfi 140 | Arnoni 141 | Arrighetti 142 | Arrighi 143 | Arrigucci 144 | Aucciello 145 | Azzarà 146 | Baggi 147 | Baggio 148 | Baglio 149 | Bagni 150 | Bagnoli 151 | Balboni 152 | Baldi 153 | Baldini 154 | Baldinotti 155 | Baldovini 156 | Bandini 157 | Bandoni 158 | Barbieri 159 | Barone 160 | Barsetti 161 | Bartalotti 162 | Bartolomei 163 | Bartolomeo 164 | Barzetti 165 | Basile 166 | Bassanelli 167 | Bassani 168 | Bassi 169 | Basso 170 | Basurto 171 | Battaglia 172 | Bazzoli 173 | Bellandi 174 | Bellandini 175 | Bellincioni 176 | Bellini 177 | Bello 178 | Bellomi 179 | Belloni 180 | Belluomi 181 | Belmonte 182 | Bencivenni 183 | Benedetti 184 | Benenati 185 | Benetton 186 | Benini 187 | Benivieni 188 | Benvenuti 189 | Berardi 190 | Bergamaschi 191 | Berti 192 | Bertolini 193 | Biancardi 194 | Bianchi 195 | Bicchieri 196 | Biondi 197 | Biondo 198 | Boerio 199 | Bologna 200 | Bondesan 201 | Bonomo 202 | Borghi 203 | Borgnino 204 | Borgogni 205 | Bosco 206 | Bove 207 | Bovér 208 | Boveri 209 | Brambani 210 | Brambilla 211 | Breda 212 | Brioschi 213 | Brivio 214 | Brunetti 215 | Bruno 216 | Buffone 217 | Bulgarelli 218 | Bulgari 219 | Buonarroti 220 | Busto 221 | Caiazzo 222 | Caito 223 | Caivano 224 | Calabrese 225 | Calligaris 226 | Campana 227 | Campo 228 | Cantu 229 | Capello 230 | Capello 231 | Capello 232 | Capitani 233 | Carbone 234 | Carboni 235 | Carideo 236 | Carlevaro 237 | Caro 238 | Carracci 239 | Carrara 240 | Caruso 241 | Cassano 242 | Castro 243 | Catalano 244 | Cattaneo 245 | Cavalcante 246 | Cavallo 247 | Cingolani 248 | Cino 249 | Cipriani 250 | Cisternino 251 | Coiro 252 | Cola 253 | Colombera 254 | Colombo 255 | Columbo 256 | Como 257 | Como 258 | Confortola 259 | Conti 260 | Corna 261 | Corti 262 | Corvi 263 | Costa 264 | Costantini 265 | Costanzo 266 | Cracchiolo 267 | Cremaschi 268 | Cremona 269 | Cremonesi 270 | Crespo 271 | Croce 272 | Crocetti 273 | Cucinotta 274 | Cuocco 275 | Cuoco 276 | D'ambrosio 277 | Damiani 278 | D'amore 279 | D'angelo 280 | D'antonio 281 | De angelis 282 | De campo 283 | De felice 284 | De filippis 285 | De fiore 286 | De laurentis 287 | De luca 288 | De palma 289 | De rege 290 | De santis 291 | De vitis 292 | Di antonio 293 | Di caprio 294 | Di mercurio 295 | Dinapoli 296 | Dioli 297 | Di pasqua 298 | Di pietro 299 | Di stefano 300 | Donati 301 | D'onofrio 302 | Drago 303 | Durante 304 | Elena 305 | Episcopo 306 | Ermacora 307 | Esposito 308 | Evangelista 309 | Fabbri 310 | Fabbro 311 | Falco 312 | Faraldo 313 | Farina 314 | Farro 315 | Fattore 316 | Fausti 317 | Fava 318 | Favero 319 | Fermi 320 | Ferrara 321 | Ferrari 322 | Ferraro 323 | Ferrero 324 | Ferro 325 | Fierro 326 | Filippi 327 | Fini 328 | Fiore 329 | Fiscella 330 | Fiscella 331 | Fonda 332 | Fontana 333 | Fortunato 334 | Franco 335 | Franzese 336 | Furlan 337 | Gabrielli 338 | Gagliardi 339 | Gallo 340 | Ganza 341 | Garfagnini 342 | Garofalo 343 | Gaspari 344 | Gatti 345 | Genovese 346 | Gentile 347 | Germano 348 | Giannino 349 | Gimondi 350 | Giordano 351 | Gismondi 352 | Giùgovaz 353 | Giunta 354 | Goretti 355 | Gori 356 | Greco 357 | Grillo 358 | Grimaldi 359 | Gronchi 360 | Guarneri 361 | Guerra 362 | Guerriero 363 | Guidi 364 | Guttuso 365 | Idoni 366 | Innocenti 367 | Labriola 368 | Làconi 369 | Laganà 370 | Lagomarsìno 371 | Lagorio 372 | Laguardia 373 | Lama 374 | Lamberti 375 | Lamon 376 | Landi 377 | Lando 378 | Landolfi 379 | Laterza 380 | Laurito 381 | Lazzari 382 | Lecce 383 | Leccese 384 | Leggièri 385 | Lèmmi 386 | Leone 387 | Leoni 388 | Lippi 389 | Locatelli 390 | Lombardi 391 | Longo 392 | Lupo 393 | Luzzatto 394 | Maestri 395 | Magro 396 | Mancini 397 | Manco 398 | Mancuso 399 | Manfredi 400 | Manfredonia 401 | Mantovani 402 | Marchegiano 403 | Marchesi 404 | Marchetti 405 | Marchioni 406 | Marconi 407 | Mari 408 | Maria 409 | Mariani 410 | Marino 411 | Marmo 412 | Martelli 413 | Martinelli 414 | Masi 415 | Masin 416 | Mazza 417 | Merlo 418 | Messana 419 | Micheli 420 | Milani 421 | Milano 422 | Modugno 423 | Mondadori 424 | Mondo 425 | Montagna 426 | Montana 427 | Montanari 428 | Monte 429 | Monti 430 | Morandi 431 | Morello 432 | Moretti 433 | Morra 434 | Moschella 435 | Mosconi 436 | Motta 437 | Muggia 438 | Muraro 439 | Murgia 440 | Murtas 441 | Nacar 442 | Naggi 443 | Naggia 444 | Naldi 445 | Nana 446 | Nani 447 | Nanni 448 | Nannini 449 | Napoleoni 450 | Napoletani 451 | Napoliello 452 | Nardi 453 | Nardo 454 | Nardovino 455 | Nasato 456 | Nascimbene 457 | Nascimbeni 458 | Natale 459 | Nave 460 | Nazario 461 | Necchi 462 | Negri 463 | Negrini 464 | Nelli 465 | Nenci 466 | Nepi 467 | Neri 468 | Neroni 469 | Nervetti 470 | Nervi 471 | Nespola 472 | Nicastro 473 | Nicchi 474 | Nicodemo 475 | Nicolai 476 | Nicolosi 477 | Nicosia 478 | Nicotera 479 | Nieddu 480 | Nieri 481 | Nigro 482 | Nisi 483 | Nizzola 484 | Noschese 485 | Notaro 486 | Notoriano 487 | Oberti 488 | Oberto 489 | Ongaro 490 | Orlando 491 | Orsini 492 | Pace 493 | Padovan 494 | Padovano 495 | Pagani 496 | Pagano 497 | Palladino 498 | Palmisano 499 | Palumbo 500 | Panzavecchia 501 | Parisi 502 | Parma 503 | Parodi 504 | Parri 505 | Parrino 506 | Passerini 507 | Pastore 508 | Paternoster 509 | Pavesi 510 | Pavone 511 | Pavoni 512 | Pecora 513 | Pedrotti 514 | Pellegrino 515 | Perugia 516 | Pesaresi 517 | Pesaro 518 | Pesce 519 | Petri 520 | Pherigo 521 | Piazza 522 | Piccirillo 523 | Piccoli 524 | Pierno 525 | Pietri 526 | Pini 527 | Piovene 528 | Piraino 529 | Pisani 530 | Pittaluga 531 | Poggi 532 | Poggio 533 | Poletti 534 | Pontecorvo 535 | Portelli 536 | Porto 537 | Portoghese 538 | Potenza 539 | Pozzi 540 | Profeta 541 | Prosdocimi 542 | Provenza 543 | Provenzano 544 | Pugliese 545 | Quaranta 546 | Quattrocchi 547 | Ragno 548 | Raimondi 549 | Rais 550 | Rana 551 | Raneri 552 | Rao 553 | Rapallino 554 | Ratti 555 | Ravenna 556 | Ré 557 | Ricchetti 558 | Ricci 559 | Riggi 560 | Righi 561 | Rinaldi 562 | Riva 563 | Rizzo 564 | Robustelli 565 | Rocca 566 | Rocchi 567 | Rocco 568 | Roma 569 | Roma 570 | Romagna 571 | Romagnoli 572 | Romano 573 | Romano 574 | Romero 575 | Roncalli 576 | Ronchi 577 | Rosa 578 | Rossi 579 | Rossini 580 | Rotolo 581 | Rovigatti 582 | Ruggeri 583 | Russo 584 | Rustici 585 | Ruzzier 586 | Sabbadin 587 | Sacco 588 | Sala 589 | Salomon 590 | Salucci 591 | Salvaggi 592 | Salvai 593 | Salvail 594 | Salvatici 595 | Salvay 596 | Sanna 597 | Sansone 598 | Santini 599 | Santoro 600 | Sapienti 601 | Sarno 602 | Sarti 603 | Sartini 604 | Sarto 605 | Savona 606 | Scarpa 607 | Scarsi 608 | Scavo 609 | Sciacca 610 | Sciacchitano 611 | Sciarra 612 | Scordato 613 | Scotti 614 | Scutese 615 | Sebastiani 616 | Sebastino 617 | Segreti 618 | Selmone 619 | Selvaggio 620 | Serafin 621 | Serafini 622 | Serpico 623 | Sessa 624 | Sgro 625 | Siena 626 | Silvestri 627 | Sinagra 628 | Sinagra 629 | Soldati 630 | Somma 631 | Sordi 632 | Soriano 633 | Sorrentino 634 | Spada 635 | Spanò 636 | Sparacello 637 | Speziale 638 | Spini 639 | Stabile 640 | Stablum 641 | Stilo 642 | Sultana 643 | Tafani 644 | Tamàro 645 | Tamboia 646 | Tanzi 647 | Tarantino 648 | Taverna 649 | Tedesco 650 | Terranova 651 | Terzi 652 | Tessaro 653 | Testa 654 | Tiraboschi 655 | Tivoli 656 | Todaro 657 | Toloni 658 | Tornincasa 659 | Toselli 660 | Tosetti 661 | Tosi 662 | Tosto 663 | Trapani 664 | Traversa 665 | Traversi 666 | Traversini 667 | Traverso 668 | Trucco 669 | Trudu 670 | Tumicelli 671 | Turati 672 | Turchi 673 | Uberti 674 | Uccello 675 | Uggeri 676 | Ughi 677 | Ungaretti 678 | Ungaro 679 | Vacca 680 | Vaccaro 681 | Valenti 682 | Valentini 683 | Valerio 684 | Varano 685 | Ventimiglia 686 | Ventura 687 | Verona 688 | Veronesi 689 | Vescovi 690 | Vespa 691 | Vestri 692 | Vicario 693 | Vico 694 | Vigo 695 | Villa 696 | Vinci 697 | Vinci 698 | Viola 699 | Vitali 700 | Viteri 701 | Voltolini 702 | Zambrano 703 | Zanetti 704 | Zangari 705 | Zappa 706 | Zeni 707 | Zini 708 | Zino 709 | Zunino 710 | -------------------------------------------------------------------------------- /data/names/Japanese.txt: -------------------------------------------------------------------------------- 1 | Abe 2 | Abukara 3 | Adachi 4 | Aida 5 | Aihara 6 | Aizawa 7 | Ajibana 8 | Akaike 9 | Akamatsu 10 | Akatsuka 11 | Akechi 12 | Akera 13 | Akimoto 14 | Akita 15 | Akiyama 16 | Akutagawa 17 | Amagawa 18 | Amaya 19 | Amori 20 | Anami 21 | Ando 22 | Anzai 23 | Aoki 24 | Arai 25 | Arakawa 26 | Araki 27 | Arakida 28 | Arato 29 | Arihyoshi 30 | Arishima 31 | Arita 32 | Ariwa 33 | Ariwara 34 | Asahara 35 | Asahi 36 | Asai 37 | Asano 38 | Asanuma 39 | Asari 40 | Ashia 41 | Ashida 42 | Ashikaga 43 | Asuhara 44 | Atshushi 45 | Ayabito 46 | Ayugai 47 | Baba 48 | Baisotei 49 | Bando 50 | Bunya 51 | Chiba 52 | Chikamatsu 53 | Chikanatsu 54 | Chino 55 | Chishu 56 | Choshi 57 | Daishi 58 | Dan 59 | Date 60 | Dazai 61 | Deguchi 62 | Deushi 63 | Doi 64 | Ebina 65 | Ebisawa 66 | Eda 67 | Egami 68 | Eguchi 69 | Ekiguchi 70 | Endo 71 | Endoso 72 | Enoki 73 | Enomoto 74 | Erizawa 75 | Eto 76 | Etsuko 77 | Ezakiya 78 | Fuchida 79 | Fugunaga 80 | Fujikage 81 | Fujimaki 82 | Fujimoto 83 | Fujioka 84 | Fujishima 85 | Fujita 86 | Fujiwara 87 | Fukao 88 | Fukayama 89 | Fukuda 90 | Fukumitsu 91 | Fukunaka 92 | Fukuoka 93 | Fukusaku 94 | Fukushima 95 | Fukuyama 96 | Fukuzawa 97 | Fumihiko 98 | Funabashi 99 | Funaki 100 | Funakoshi 101 | Furusawa 102 | Fuschida 103 | Fuse 104 | Futabatei 105 | Fuwa 106 | Gakusha 107 | Genda 108 | Genji 109 | Gensai 110 | Godo 111 | Goto 112 | Gushiken 113 | Hachirobei 114 | Haga 115 | Hagino 116 | Hagiwara 117 | Hama 118 | Hamacho 119 | Hamada 120 | Hamaguchi 121 | Hamamoto 122 | Hanabusa 123 | Hanari 124 | Handa 125 | Hara 126 | Harada 127 | Haruguchi 128 | Hasegawa 129 | Hasekura 130 | Hashimoto 131 | Hasimoto 132 | Hatakeda 133 | Hatakeyama 134 | Hatayama 135 | Hatoyama 136 | Hattori 137 | Hayakawa 138 | Hayami 139 | Hayashi 140 | Hayashida 141 | Hayata 142 | Hayuata 143 | Hida 144 | Hideaki 145 | Hideki 146 | Hideyoshi 147 | Higashikuni 148 | Higashiyama 149 | Higo 150 | Higoshi 151 | Higuchi 152 | Hike 153 | Hino 154 | Hira 155 | Hiraga 156 | Hiraki 157 | Hirano 158 | Hiranuma 159 | Hiraoka 160 | Hirase 161 | Hirasi 162 | Hirata 163 | Hiratasuka 164 | Hirayama 165 | Hiro 166 | Hirose 167 | Hirota 168 | Hiroyuki 169 | Hisamatsu 170 | Hishida 171 | Hishikawa 172 | Hitomi 173 | Hiyama 174 | Hohki 175 | Hojo 176 | Hokusai 177 | Honami 178 | Honda 179 | Hori 180 | Horigome 181 | Horigoshi 182 | Horiuchi 183 | Horri 184 | Hoshino 185 | Hosokawa 186 | Hosokaya 187 | Hotate 188 | Hotta 189 | Hyata 190 | Hyobanshi 191 | Ibi 192 | Ibu 193 | Ibuka 194 | Ichigawa 195 | Ichihara 196 | Ichikawa 197 | Ichimonji 198 | Ichiro 199 | Ichisada 200 | Ichiyusai 201 | Idane 202 | Iemochi 203 | Ienari 204 | Iesada 205 | Ieyasu 206 | Ieyoshi 207 | Igarashi 208 | Ihara 209 | Ii 210 | Iida 211 | Iijima 212 | Iitaka 213 | Ijichi 214 | Ijiri 215 | Ikeda 216 | Ikina 217 | Ikoma 218 | Imada 219 | Imagawa 220 | Imai 221 | Imaizumi 222 | Imamura 223 | Imoo 224 | Ina 225 | Inaba 226 | Inao 227 | Inihara 228 | Ino 229 | Inoguchi 230 | Inokuma 231 | Inoue 232 | Inouye 233 | Inukai 234 | Ippitsusai 235 | Irie 236 | Iriye 237 | Isayama 238 | Ise 239 | Iseki 240 | Iseya 241 | Ishibashi 242 | Ishida 243 | Ishiguro 244 | Ishihara 245 | Ishikawa 246 | Ishimaru 247 | Ishimura 248 | Ishinomori 249 | Ishiyama 250 | Isobe 251 | Isoda 252 | Isozaki 253 | Itagaki 254 | Itami 255 | Ito 256 | Itoh 257 | Iwahara 258 | Iwahashi 259 | Iwakura 260 | Iwasa 261 | Iwasaki 262 | Izumi 263 | Jimbo 264 | Jippensha 265 | Jo 266 | Joshuya 267 | Joshuyo 268 | Jukodo 269 | Jumonji 270 | Kada 271 | Kagabu 272 | Kagawa 273 | Kahae 274 | Kahaya 275 | Kaibara 276 | Kaima 277 | Kajahara 278 | Kajitani 279 | Kajiwara 280 | Kajiyama 281 | Kakinomoto 282 | Kakutama 283 | Kamachi 284 | Kamata 285 | Kaminaga 286 | Kamio 287 | Kamioka 288 | Kamisaka 289 | Kamo 290 | Kamon 291 | Kan 292 | Kanada 293 | Kanagaki 294 | Kanegawa 295 | Kaneko 296 | Kanesaka 297 | Kano 298 | Karamorita 299 | Karube 300 | Karubo 301 | Kasahara 302 | Kasai 303 | Kasamatsu 304 | Kasaya 305 | Kase 306 | Kashiwagi 307 | Kasuse 308 | Kataoka 309 | Katayama 310 | Katayanagi 311 | Kate 312 | Kato 313 | Katoaka 314 | Katsu 315 | Katsukawa 316 | Katsumata 317 | Katsura 318 | Katsushika 319 | Kawabata 320 | Kawachi 321 | Kawagichi 322 | Kawagishi 323 | Kawaguchi 324 | Kawai 325 | Kawaii 326 | Kawakami 327 | Kawamata 328 | Kawamura 329 | Kawasaki 330 | Kawasawa 331 | Kawashima 332 | Kawasie 333 | Kawatake 334 | Kawate 335 | Kawayama 336 | Kawazu 337 | Kaza 338 | Kazuyoshi 339 | Kenkyusha 340 | Kenmotsu 341 | Kentaro 342 | Ki 343 | Kido 344 | Kihara 345 | Kijimuta 346 | Kijmuta 347 | Kikkawa 348 | Kikuchi 349 | Kikugawa 350 | Kikui 351 | Kikutake 352 | Kimio 353 | Kimiyama 354 | Kimura 355 | Kinashita 356 | Kinoshita 357 | Kinugasa 358 | Kira 359 | Kishi 360 | Kiski 361 | Kita 362 | Kitabatake 363 | Kitagawa 364 | Kitamura 365 | Kitano 366 | Kitao 367 | Kitoaji 368 | Ko 369 | Kobayashi 370 | Kobi 371 | Kodama 372 | Koga 373 | Kogara 374 | Kogo 375 | Koguchi 376 | Koiso 377 | Koizumi 378 | Kojima 379 | Kokan 380 | Komagata 381 | Komatsu 382 | Komatsuzaki 383 | Komine 384 | Komiya 385 | Komon 386 | Komura 387 | Kon 388 | Konae 389 | Konda 390 | Kondo 391 | Konishi 392 | Kono 393 | Konoe 394 | Koruba 395 | Koshin 396 | Kotara 397 | Kotoku 398 | Koyama 399 | Koyanagi 400 | Kozu 401 | Kubo 402 | Kubota 403 | Kudara 404 | Kudo 405 | Kuga 406 | Kumagae 407 | Kumasaka 408 | Kunda 409 | Kunikida 410 | Kunisada 411 | Kuno 412 | Kunomasu 413 | Kuramochi 414 | Kuramoto 415 | Kurata 416 | Kurkawa 417 | Kurmochi 418 | Kuroda 419 | Kurofuji 420 | Kurogane 421 | Kurohiko 422 | Kuroki 423 | Kurosawa 424 | Kurusu 425 | Kusatsu 426 | Kusonoki 427 | Kusuhara 428 | Kusunoki 429 | Kuwabara 430 | Kwakami 431 | Kyubei 432 | Maeda 433 | Maehata 434 | Maeno 435 | Maita 436 | Makiguchi 437 | Makino 438 | Makioka 439 | Makuda 440 | Marubeni 441 | Marugo 442 | Marusa 443 | Maruya 444 | Maruyama 445 | Masanobu 446 | Masaoka 447 | Mashita 448 | Masoni 449 | Masudu 450 | Masuko 451 | Masuno 452 | Masuzoe 453 | Matano 454 | Matokai 455 | Matoke 456 | Matsuda 457 | Matsukata 458 | Matsuki 459 | Matsumara 460 | Matsumoto 461 | Matsumura 462 | Matsuo 463 | Matsuoka 464 | Matsura 465 | Matsushina 466 | Matsushita 467 | Matsuya 468 | Matsuzawa 469 | Mayuzumi 470 | Mazaki 471 | Mazawa 472 | Mazuka 473 | Mifune 474 | Mihashi 475 | Miki 476 | Mimasuya 477 | Minabuchi 478 | Minami 479 | Minamoto 480 | Minatoya 481 | Minobe 482 | Mishima 483 | Mitsubishi 484 | Mitsuharu 485 | Mitsui 486 | Mitsukuri 487 | Mitsuwa 488 | Mitsuya 489 | Mitzusaka 490 | Miura 491 | Miwa 492 | Miyagi 493 | Miyahara 494 | Miyajima 495 | Miyake 496 | Miyamae 497 | Miyamoto 498 | Miyazaki 499 | Miyazawa 500 | Miyoshi 501 | Mizoguchi 502 | Mizumaki 503 | Mizuno 504 | Mizutani 505 | Modegi 506 | Momotami 507 | Momotani 508 | Monomonoi 509 | Mori 510 | Moriguchi 511 | Morimoto 512 | Morinaga 513 | Morioka 514 | Morishita 515 | Morisue 516 | Morita 517 | Morri 518 | Moto 519 | Motoori 520 | Motoyoshi 521 | Munakata 522 | Munkata 523 | Muraguchi 524 | Murakami 525 | Muraoka 526 | Murasaki 527 | Murase 528 | Murata 529 | Murkami 530 | Muro 531 | Muruyama 532 | Mushanaokoji 533 | Mushashibo 534 | Muso 535 | Mutsu 536 | Nagahama 537 | Nagai 538 | Nagano 539 | Nagasawa 540 | Nagase 541 | Nagata 542 | Nagatsuka 543 | Nagumo 544 | Naito 545 | Nakada 546 | Nakadai 547 | Nakadan 548 | Nakae 549 | Nakagawa 550 | Nakahara 551 | Nakajima 552 | Nakamoto 553 | Nakamura 554 | Nakane 555 | Nakanishi 556 | Nakano 557 | Nakanoi 558 | Nakao 559 | Nakasato 560 | Nakasawa 561 | Nakasone 562 | Nakata 563 | Nakatoni 564 | Nakayama 565 | Nakazawa 566 | Namiki 567 | Nanami 568 | Narahashi 569 | Narato 570 | Narita 571 | Nataga 572 | Natsume 573 | Nawabe 574 | Nemoto 575 | Niijima 576 | Nijo 577 | Ninomiya 578 | Nishi 579 | Nishihara 580 | Nishikawa 581 | Nishimoto 582 | Nishimura 583 | Nishimuraya 584 | Nishio 585 | Nishiwaki 586 | Nitta 587 | Nobunaga 588 | Noda 589 | Nogi 590 | Noguchi 591 | Nogushi 592 | Nomura 593 | Nonomura 594 | Noro 595 | Nosaka 596 | Nose 597 | Nozaki 598 | Nozara 599 | Numajiri 600 | Numata 601 | Obata 602 | Obinata 603 | Obuchi 604 | Ochiai 605 | Ochida 606 | Odaka 607 | Ogata 608 | Ogiwara 609 | Ogura 610 | Ogyu 611 | Ohba 612 | Ohira 613 | Ohishi 614 | Ohka 615 | Ohmae 616 | Ohmiya 617 | Oichi 618 | Oinuma 619 | Oishi 620 | Okabe 621 | Okada 622 | Okakura 623 | Okamoto 624 | Okamura 625 | Okanao 626 | Okanaya 627 | Okano 628 | Okasawa 629 | Okawa 630 | Okazaki 631 | Okazawaya 632 | Okimasa 633 | Okimoto 634 | Okita 635 | Okubo 636 | Okuda 637 | Okui 638 | Okuma 639 | Okuma 640 | Okumura 641 | Okura 642 | Omori 643 | Omura 644 | Onishi 645 | Ono 646 | Onoda 647 | Onoe 648 | Onohara 649 | Ooka 650 | Osagawa 651 | Osaragi 652 | Oshima 653 | Oshin 654 | Ota 655 | Otaka 656 | Otake 657 | Otani 658 | Otomo 659 | Otsu 660 | Otsuka 661 | Ouchi 662 | Oyama 663 | Ozaki 664 | Ozawa 665 | Ozu 666 | Raikatuji 667 | Royama 668 | Ryusaki 669 | Sada 670 | Saeki 671 | Saga 672 | Saigo 673 | Saiki 674 | Saionji 675 | Saito 676 | Saitoh 677 | Saji 678 | Sakagami 679 | Sakai 680 | Sakakibara 681 | Sakamoto 682 | Sakanoue 683 | Sakata 684 | Sakiyurai 685 | Sakoda 686 | Sakubara 687 | Sakuraba 688 | Sakurai 689 | Sammiya 690 | Sanda 691 | Sanjo 692 | Sano 693 | Santo 694 | Saromi 695 | Sarumara 696 | Sasada 697 | Sasakawa 698 | Sasaki 699 | Sassa 700 | Satake 701 | Sato 702 | Satoh 703 | Satoya 704 | Sawamatsu 705 | Sawamura 706 | Sayuki 707 | Segawa 708 | Sekigawa 709 | Sekine 710 | Sekozawa 711 | Sen 712 | Senmatsu 713 | Seo 714 | Serizawa 715 | Shiba 716 | Shibaguchi 717 | Shibanuma 718 | Shibasaki 719 | Shibasawa 720 | Shibata 721 | Shibukji 722 | Shichirobei 723 | Shidehara 724 | Shiga 725 | Shiganori 726 | Shige 727 | Shigeki 728 | Shigemitsu 729 | Shigi 730 | Shikitei 731 | Shikuk 732 | Shima 733 | Shimada 734 | Shimakage 735 | Shimamura 736 | Shimanouchi 737 | Shimaoka 738 | Shimazaki 739 | Shimazu 740 | Shimedzu 741 | Shimizu 742 | Shimohira 743 | Shimon 744 | Shimura 745 | Shimuzu 746 | Shinko 747 | Shinozaki 748 | Shinozuka 749 | Shintaro 750 | Shiokawa 751 | Shiomi 752 | Shiomiya 753 | Shionoya 754 | Shiotani 755 | Shioya 756 | Shirahata 757 | Shirai 758 | Shiraishi 759 | Shirane 760 | Shirasu 761 | Shiratori 762 | Shirokawa 763 | Shiroyama 764 | Shiskikura 765 | Shizuma 766 | Shobo 767 | Shoda 768 | Shunji 769 | Shunsen 770 | Siagyo 771 | Soga 772 | Sohda 773 | Soho 774 | Soma 775 | Someya 776 | Sone 777 | Sonoda 778 | Soseki 779 | Sotomura 780 | Suenami 781 | Sugai 782 | Sugase 783 | Sugawara 784 | Sugihara 785 | Sugimura 786 | Sugisata 787 | Sugita 788 | Sugitani 789 | Sugiyama 790 | Sumitimo 791 | Sunada 792 | Suzambo 793 | Suzuki 794 | Tabuchi 795 | Tadeshi 796 | Tagawa 797 | Taguchi 798 | Taira 799 | Taka 800 | Takabe 801 | Takagaki 802 | Takagawa 803 | Takagi 804 | Takahama 805 | Takahashi 806 | Takaki 807 | Takamura 808 | Takano 809 | Takaoka 810 | Takara 811 | Takarabe 812 | Takashi 813 | Takashita 814 | Takasu 815 | Takasugi 816 | Takayama 817 | Takecare 818 | Takeda 819 | Takei 820 | Takekawa 821 | Takemago 822 | Takemitsu 823 | Takemura 824 | Takenouchi 825 | Takeshita 826 | Taketomo 827 | Takeuchi 828 | Takewaki 829 | Takimoto 830 | Takishida 831 | Takishita 832 | Takizawa 833 | Taku 834 | Takudo 835 | Takudome 836 | Tamazaki 837 | Tamura 838 | Tamuro 839 | Tanaka 840 | Tange 841 | Tani 842 | Taniguchi 843 | Tanizaki 844 | Tankoshitsu 845 | Tansho 846 | Tanuma 847 | Tarumi 848 | Tatenaka 849 | Tatsuko 850 | Tatsuno 851 | Tatsuya 852 | Tawaraya 853 | Tayama 854 | Temko 855 | Tenshin 856 | Terada 857 | Terajima 858 | Terakado 859 | Terauchi 860 | Teshigahara 861 | Teshima 862 | Tochikura 863 | Togo 864 | Tojo 865 | Tokaji 866 | Tokuda 867 | Tokudome 868 | Tokuoka 869 | Tomika 870 | Tomimoto 871 | Tomioka 872 | Tommii 873 | Tomonaga 874 | Tomori 875 | Tono 876 | Torii 877 | Torisei 878 | Toru 879 | Toshishai 880 | Toshitala 881 | Toshusai 882 | Toyama 883 | Toyoda 884 | Toyoshima 885 | Toyota 886 | Toyotomi 887 | Tsubouchi 888 | Tsucgimoto 889 | Tsuchie 890 | Tsuda 891 | Tsuji 892 | Tsujimoto 893 | Tsujimura 894 | Tsukada 895 | Tsukade 896 | Tsukahara 897 | Tsukamoto 898 | Tsukatani 899 | Tsukawaki 900 | Tsukehara 901 | Tsukioka 902 | Tsumemasa 903 | Tsumura 904 | Tsunoda 905 | Tsurimi 906 | Tsuruga 907 | Tsuruya 908 | Tsushima 909 | Tsutaya 910 | Tsutomu 911 | Uboshita 912 | Uchida 913 | Uchiyama 914 | Ueda 915 | Uehara 916 | Uemura 917 | Ueshima 918 | Uesugi 919 | Uetake 920 | Ugaki 921 | Ui 922 | Ukiyo 923 | Umari 924 | Umehara 925 | Umeki 926 | Uno 927 | Uoya 928 | Urogataya 929 | Usami 930 | Ushiba 931 | Utagawa 932 | Wakai 933 | Wakatsuki 934 | Watabe 935 | Watanabe 936 | Watari 937 | Watnabe 938 | Watoga 939 | Yakuta 940 | Yamabe 941 | Yamada 942 | Yamagata 943 | Yamaguchi 944 | Yamaguchiya 945 | Yamaha 946 | Yamahata 947 | Yamakage 948 | Yamakawa 949 | Yamakazi 950 | Yamamoto 951 | Yamamura 952 | Yamana 953 | Yamanaka 954 | Yamanouchi 955 | Yamanoue 956 | Yamaoka 957 | Yamashita 958 | Yamato 959 | Yamawaki 960 | Yamazaki 961 | Yamhata 962 | Yamura 963 | Yanagawa 964 | Yanagi 965 | Yanagimoto 966 | Yanagita 967 | Yano 968 | Yasuda 969 | Yasuhiro 970 | Yasui 971 | Yasujiro 972 | Yasukawa 973 | Yasutake 974 | Yoemon 975 | Yokokawa 976 | Yokoyama 977 | Yonai 978 | Yosano 979 | Yoshida 980 | Yoshifumi 981 | Yoshihara 982 | Yoshikawa 983 | Yoshimatsu 984 | Yoshinobu 985 | Yoshioka 986 | Yoshitomi 987 | Yoshizaki 988 | Yoshizawa 989 | Yuasa 990 | Yuhara 991 | Yunokawa 992 | -------------------------------------------------------------------------------- /data/names/Korean.txt: -------------------------------------------------------------------------------- 1 | Ahn 2 | Baik 3 | Bang 4 | Byon 5 | Cha 6 | Chang 7 | Chi 8 | Chin 9 | Cho 10 | Choe 11 | Choi 12 | Chong 13 | Chou 14 | Chu 15 | Chun 16 | Chung 17 | Chweh 18 | Gil 19 | Gu 20 | Gwang 21 | Ha 22 | Han 23 | Ho 24 | Hong 25 | Hung 26 | Hwang 27 | Hyun 28 | Jang 29 | Jeon 30 | Jeong 31 | Jo 32 | Jon 33 | Jong 34 | Jung 35 | Kang 36 | Kim 37 | Ko 38 | Koo 39 | Ku 40 | Kwak 41 | Kwang 42 | Lee 43 | Li 44 | Lim 45 | Ma 46 | Mo 47 | Moon 48 | Nam 49 | Ngai 50 | Noh 51 | Oh 52 | Pae 53 | Pak 54 | Park 55 | Ra 56 | Rhee 57 | Rheem 58 | Ri 59 | Rim 60 | Ron 61 | Ryom 62 | Ryoo 63 | Ryu 64 | San 65 | Seo 66 | Seok 67 | Shim 68 | Shin 69 | Shon 70 | Si 71 | Sin 72 | So 73 | Son 74 | Song 75 | Sook 76 | Suh 77 | Suk 78 | Sun 79 | Sung 80 | Tsai 81 | Wang 82 | Woo 83 | Yang 84 | Yeo 85 | Yeon 86 | Yi 87 | Yim 88 | Yoo 89 | Yoon 90 | You 91 | Youj 92 | Youn 93 | Yu 94 | Yun 95 | -------------------------------------------------------------------------------- /data/names/Polish.txt: -------------------------------------------------------------------------------- 1 | Adamczak 2 | Adamczyk 3 | Andrysiak 4 | Auttenberg 5 | Bartosz 6 | Bernard 7 | Bobienski 8 | Bosko 9 | Broż 10 | Brzezicki 11 | Budny 12 | Bukoski 13 | Bukowski 14 | Chlebek 15 | Chmiel 16 | Czajka 17 | Czajkowski 18 | Dubanowski 19 | Dubicki 20 | Dunajski 21 | Dziedzic 22 | Fabian 23 | Filipek 24 | Filipowski 25 | Gajos 26 | Gniewek 27 | Gomolka 28 | Gomulka 29 | Gorecki 30 | Górka 31 | Górski 32 | Grzeskiewicz 33 | Gwozdek 34 | Jagoda 35 | Janda 36 | Janowski 37 | Jaskolski 38 | Jaskulski 39 | Jedynak 40 | Jelen 41 | Jez 42 | Jordan 43 | Kaczka 44 | Kaluza 45 | Kamiński 46 | Kasprzak 47 | Kava 48 | Kedzierski 49 | Kijek 50 | Klimek 51 | Kosmatka 52 | Kowalczyk 53 | Kowalski 54 | Koziol 55 | Kozlow 56 | Kozlowski 57 | Krakowski 58 | Król 59 | Kumiega 60 | Lawniczak 61 | Lis 62 | Majewski 63 | Malinowski 64 | Maly 65 | Marek 66 | Marszałek 67 | Maslanka 68 | Mencher 69 | Miazga 70 | Michel 71 | Mikolajczak 72 | Mozdzierz 73 | Niemczyk 74 | Niemec 75 | Nosek 76 | Nowak 77 | Pakulski 78 | Pasternack 79 | Pasternak 80 | Paszek 81 | Piatek 82 | Piontek 83 | Pokorny 84 | Poplawski 85 | Róg 86 | Rudaski 87 | Rudawski 88 | Rusnak 89 | Rutkowski 90 | Sadowski 91 | Salomon 92 | Serafin 93 | Sienkiewicz 94 | Sierzant 95 | Sitko 96 | Skala 97 | Slaski 98 | Ślązak 99 | Ślusarczyk 100 | Ślusarski 101 | Smolák 102 | Sniegowski 103 | Sobol 104 | Sokal 105 | Sokolof 106 | Sokoloff 107 | Sokolofsky 108 | Sokolowski 109 | Sokolsky 110 | Sówka 111 | Stanek 112 | Starek 113 | Stawski 114 | Stolarz 115 | Szczepanski 116 | Szewc 117 | Szwarc 118 | Szweda 119 | Szwedko 120 | Walentowicz 121 | Warszawski 122 | Wawrzaszek 123 | Wiater 124 | Winograd 125 | Winogrodzki 126 | Wojda 127 | Wojewódka 128 | Wojewódzki 129 | Wronski 130 | Wyrick 131 | Wyrzyk 132 | Zabek 133 | Zawisza 134 | Zdunowski 135 | Zdunowski 136 | Zielinski 137 | Ziemniak 138 | Zientek 139 | Żuraw 140 | -------------------------------------------------------------------------------- /data/names/Portuguese.txt: -------------------------------------------------------------------------------- 1 | Abreu 2 | Albuquerque 3 | Almeida 4 | Alves 5 | Araújo 6 | Araullo 7 | Barros 8 | Basurto 9 | Belo 10 | Cabral 11 | Campos 12 | Cardozo 13 | Castro 14 | Coelho 15 | Costa 16 | Crespo 17 | Cruz 18 | D'cruz 19 | D'cruze 20 | Delgado 21 | De santigo 22 | Duarte 23 | Estéves 24 | Fernandes 25 | Ferreira 26 | Ferreiro 27 | Ferro 28 | Fonseca 29 | Franco 30 | Freitas 31 | Garcia 32 | Gaspar 33 | Gomes 34 | Gouveia 35 | Guerra 36 | Henriques 37 | Lobo 38 | Machado 39 | Madeira 40 | Magalhães 41 | Maria 42 | Mata 43 | Mateus 44 | Matos 45 | Medeiros 46 | Melo 47 | Mendes 48 | Moreno 49 | Nunes 50 | Palmeiro 51 | Paredes 52 | Pereira 53 | Pinheiro 54 | Pinho 55 | Ramires 56 | Ribeiro 57 | Rios 58 | Rocha 59 | Rodrigues 60 | Romão 61 | Rosario 62 | Salazar 63 | Santana 64 | Santiago 65 | Santos 66 | Serafim 67 | Silva 68 | Silveira 69 | Simões 70 | Soares 71 | Souza 72 | Torres 73 | Vargas 74 | Ventura 75 | -------------------------------------------------------------------------------- /data/names/Scottish.txt: -------------------------------------------------------------------------------- 1 | Smith 2 | Brown 3 | Wilson 4 | Campbell 5 | Stewart 6 | Thomson 7 | Robertson 8 | Anderson 9 | Macdonald 10 | Scott 11 | Reid 12 | Murray 13 | Taylor 14 | Clark 15 | Ross 16 | Watson 17 | Morrison 18 | Paterson 19 | Young 20 | Mitchell 21 | Walker 22 | Fraser 23 | Miller 24 | Mcdonald 25 | Gray 26 | Henderson 27 | Hamilton 28 | Johnston 29 | Duncan 30 | Graham 31 | Ferguson 32 | Kerr 33 | Davidson 34 | Bell 35 | Cameron 36 | Kelly 37 | Martin 38 | Hunter 39 | Allan 40 | Mackenzie 41 | Grant 42 | Simpson 43 | Mackay 44 | Mclean 45 | Macleod 46 | Black 47 | Russell 48 | Marshall 49 | Wallace 50 | Gibson 51 | Kennedy 52 | Gordon 53 | Burns 54 | Sutherland 55 | Stevenson 56 | Munro 57 | Milne 58 | Watt 59 | Murphy 60 | Craig 61 | Wood 62 | Muir 63 | Wright 64 | Mckenzie 65 | Ritchie 66 | Johnstone 67 | Sinclair 68 | White 69 | Mcmillan 70 | Williamson 71 | Dickson 72 | Hughes 73 | Cunningham 74 | Mckay 75 | Bruce 76 | Millar 77 | Crawford 78 | Mcintosh 79 | Douglas 80 | Docherty 81 | King 82 | Jones 83 | Boyle 84 | Fleming 85 | Mcgregor 86 | Aitken 87 | Christie 88 | Shaw 89 | Maclean 90 | Jamieson 91 | Mcintyre 92 | Hay 93 | Lindsay 94 | Alexander 95 | Ramsay 96 | Mccallum 97 | Whyte 98 | Jackson 99 | Mclaughlin 100 | Hill 101 | -------------------------------------------------------------------------------- /data/names/Spanish.txt: -------------------------------------------------------------------------------- 1 | Abana 2 | Abano 3 | Abarca 4 | Abaroa 5 | Abascal 6 | Abasolo 7 | Abel 8 | Abelló 9 | Aberquero 10 | Abreu 11 | Acosta 12 | Agramunt 13 | Aiza 14 | Alamilla 15 | Albert 16 | Albuquerque 17 | Aldana 18 | Alfaro 19 | Alvarado 20 | Álvarez 21 | Alves 22 | Amador 23 | Andreu 24 | Antúnez 25 | Aqua 26 | Aquino 27 | Araújo 28 | Araullo 29 | Araya 30 | Arce 31 | Arechavaleta 32 | Arena 33 | Aritza 34 | Armando 35 | Arreola 36 | Arriola 37 | Asis 38 | Asturias 39 | Avana 40 | Azarola 41 | Banderas 42 | Barros 43 | Basurto 44 | Bautista 45 | Bello 46 | Belmonte 47 | Bengochea 48 | Benitez 49 | Bermúdez 50 | Blanco 51 | Blanxart 52 | Bolívar 53 | Bonaventura 54 | Bosque 55 | Bustillo 56 | Busto 57 | Bustos 58 | Cabello 59 | Cabrera 60 | Campo 61 | Campos 62 | Capello 63 | Cardona 64 | Caro 65 | Casales 66 | Castell 67 | Castellano 68 | Castillion 69 | Castillo 70 | Castro 71 | Chavarría 72 | Chavez 73 | Colón 74 | Costa 75 | Crespo 76 | Cruz 77 | Cuéllar 78 | Cuevas 79 | D'cruz 80 | D'cruze 81 | De la cruz 82 | De la fuente 83 | Del bosque 84 | De leon 85 | Delgado 86 | Del olmo 87 | De santigo 88 | Díaz 89 | Dominguez 90 | Duarte 91 | Durante 92 | Echevarría 93 | Echeverría 94 | Elizondo 95 | Escamilla 96 | Escárcega 97 | Escarrà 98 | Esparza 99 | Espina 100 | Espino 101 | Espinosa 102 | Espinoza 103 | Estévez 104 | Etxebarria 105 | Etxeberria 106 | Félix 107 | Fernández 108 | Ferrer 109 | Fierro 110 | Flores 111 | Fonseca 112 | Franco 113 | Fuentes 114 | Gallego 115 | Gallo 116 | García 117 | Garrastazu 118 | Garza 119 | Gaspar 120 | Gebara 121 | Gomez 122 | Gonzales 123 | Gonzalez 124 | Grec 125 | Guadarrama 126 | Guerra 127 | Guerrero 128 | Gutiérrez 129 | Gutierrez 130 | Hernandez 131 | Herrera 132 | Herrero 133 | Hierro 134 | Holguín 135 | Huerta 136 | Ibáñez 137 | Ibarra 138 | Iñíguez 139 | Iturburua 140 | Jaso 141 | Jasso 142 | Jimenez 143 | Jordà 144 | Juárez 145 | Lobo 146 | Lopez 147 | Losa 148 | Loyola 149 | Machado 150 | Macías 151 | Maradona 152 | María 153 | Marino 154 | Márquez 155 | Martell 156 | Martí 157 | Martínez 158 | Martinez 159 | Mas 160 | Mata 161 | Mateu 162 | Medina 163 | Melendez 164 | Méndez 165 | Mendoza 166 | Menendez 167 | Merlo 168 | Michel 169 | Mingo 170 | Moles 171 | Molina 172 | Montero 173 | Morales 174 | Moralez 175 | Moreno 176 | Narváez 177 | Nieves 178 | Noguerra 179 | Núñez 180 | Obando 181 | Ochoa 182 | Ojeda 183 | Ola 184 | Oleastro 185 | Olguin 186 | Oliver 187 | Olmos 188 | Oquendo 189 | Orellana 190 | Oriol 191 | Ortega 192 | Ortiz 193 | Palomo 194 | Paredes 195 | Pavia 196 | Peláez 197 | Peña 198 | Pérez 199 | Perez 200 | Petit 201 | Picasso 202 | Porra 203 | Porras 204 | Prieto 205 | Puerta 206 | Puga 207 | Puig 208 | Quinones 209 | Quintana 210 | Quirós 211 | Ramírez 212 | Ramos 213 | Rana 214 | Rendón 215 | Rey 216 | Reyes 217 | Rios 218 | Rivera 219 | Rivero 220 | Robledo 221 | Robles 222 | Rocha 223 | Rodríguez 224 | Rodriquez 225 | Roig 226 | Rojas 227 | Rojo 228 | Roldán 229 | Romà 230 | Romà 231 | Romero 232 | Rosa 233 | Rosales 234 | Rubio 235 | Ruiz 236 | Sala 237 | Salamanca 238 | Salazar 239 | Salcedo 240 | Salinas 241 | Sanchez 242 | Sandoval 243 | San nicolas 244 | Santana 245 | Santiago 246 | Santillian 247 | Santos 248 | Sastre 249 | Sepúlveda 250 | Sierra 251 | Silva 252 | Soler 253 | Solo 254 | Solos 255 | Soto 256 | Suárez 257 | Suero 258 | Tapia 259 | Terrazas 260 | Tomàs 261 | Torres 262 | Tos 263 | Tosell 264 | Toset 265 | Travieso 266 | Trujillo 267 | Ubina 268 | Urbina 269 | Ureña 270 | Valdez 271 | Valencia 272 | Varela 273 | Vargas 274 | Vásquez 275 | Vázquez 276 | Vega 277 | Vela 278 | Vela 279 | Velazquez 280 | Ventura 281 | Vicario 282 | Vilaró 283 | Villa 284 | Villalobos 285 | Villanueva 286 | Villaverde 287 | Viola 288 | Viteri 289 | Vivas 290 | Vives 291 | Ybarra 292 | Zabala 293 | Zambrano 294 | Zamorano 295 | Zapatero 296 | Zavala 297 | Zubizarreta 298 | Zuñiga 299 | -------------------------------------------------------------------------------- /data/names/Vietnamese.txt: -------------------------------------------------------------------------------- 1 | Nguyen 2 | Tron 3 | Le 4 | Pham 5 | Huynh 6 | Hoang 7 | Phan 8 | Vu 9 | Vo 10 | Dang 11 | Bui 12 | Do 13 | Ho 14 | Ngo 15 | Duong 16 | Ly 17 | An 18 | an 19 | Bach 20 | Banh 21 | Cao 22 | Chau 23 | Chu 24 | Chung 25 | Chu 26 | Diep 27 | Doan 28 | Dam 29 | Dao 30 | Dinh 31 | Doan 32 | Giang 33 | Ha 34 | Han 35 | Kieu 36 | Kim 37 | La 38 | Lac 39 | Lam 40 | Lieu 41 | Luc 42 | Luong 43 | Luu 44 | Ma 45 | Mach 46 | Mai 47 | Nghiem 48 | Phi 49 | Pho 50 | Phung 51 | Quach 52 | Quang 53 | Quyen 54 | Ta 55 | Thach 56 | Thai 57 | Sai 58 | Thi 59 | Than 60 | Thao 61 | Thuy 62 | Tieu 63 | To 64 | Ton 65 | Tong 66 | Trang 67 | Trieu 68 | Trinh 69 | Truong 70 | Van 71 | Vinh 72 | Vuong 73 | Vuu 74 | -------------------------------------------------------------------------------- /glove-word-vectors/glove-word-vectors.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "![](https://i.imgur.com/eBRPvWB.png)\n", 8 | "\n", 9 | "# Practical PyTorch: Exploring Word Vectors with GloVe\n", 10 | "\n", 11 | "When working with words, dealing with the huge but sparse domain of language can be challenging. Even for a small corpus, your neural network (or any type of model) needs to support many thousands of discrete inputs and outputs.\n", 12 | "\n", 13 | "Besides the raw number words, the standard technique of representing words as one-hot vectors (e.g. \"the\" = `[0 0 0 1 0 0 0 0 ...]`) does not capture any information about relationships between words.\n", 14 | "\n", 15 | "Word vectors address this problem by representing words in a multi-dimensional vector space. This can bring the dimensionality of the problem from hundreds-of-thousands to just hundreds. Plus, the vector space is able to capture semantic relationships between words in terms of distance and vector arithmetic.\n", 16 | "\n", 17 | "![](https://i.imgur.com/y4hG1ak.png)\n", 18 | "\n", 19 | "There are a few techniques for creating word vectors. The word2vec algorithm predicts words in a context (e.g. what is the most likely word to appear in \"the cat ? the mouse\"), while GloVe vectors are based on global counts across the corpus — see [How is GloVe different from word2vec?](https://www.quora.com/How-is-GloVe-different-from-word2vec) on Quora for some better explanations.\n", 20 | "\n", 21 | "In my opinion the best feature of GloVe is that multiple sets of pre-trained vectors are easily [available for download](https://nlp.stanford.edu/projects/glove/), so that's what we'll use here.\n", 22 | "\n", 23 | "## Recommended reading\n", 24 | "\n", 25 | "* https://blog.acolyer.org/2016/04/21/the-amazing-power-of-word-vectors/\n", 26 | "* https://blog.acolyer.org/2016/04/22/glove-global-vectors-for-word-representation/\n", 27 | "* https://levyomer.wordpress.com/2014/04/25/linguistic-regularities-in-sparse-and-explicit-word-representations/" 28 | ] 29 | }, 30 | { 31 | "cell_type": "markdown", 32 | "metadata": {}, 33 | "source": [ 34 | "## Installing torchtext\n", 35 | "\n", 36 | "The torchtext package is not currently on the PIP or Conda package managers, but it's easy to install manually:\n", 37 | "\n", 38 | "```\n", 39 | "git clone https://github.com/pytorch/text pytorch-text\n", 40 | "cd pytorch-text\n", 41 | "python setup.py install\n", 42 | "```" 43 | ] 44 | }, 45 | { 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "## Loading word vectors\n", 50 | "\n", 51 | "Torchtext includes functions to download GloVe (and other) embeddings" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 1, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "import torch\n", 61 | "import torchtext.vocab as vocab" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 2, 67 | "metadata": {}, 68 | "outputs": [ 69 | { 70 | "name": "stdout", 71 | "output_type": "stream", 72 | "text": [ 73 | "Loaded 400000 words\n" 74 | ] 75 | } 76 | ], 77 | "source": [ 78 | "glove = vocab.GloVe(name='6B', dim=100)\n", 79 | "\n", 80 | "print('Loaded {} words'.format(len(glove.itos)))" 81 | ] 82 | }, 83 | { 84 | "cell_type": "markdown", 85 | "metadata": {}, 86 | "source": [ 87 | "The returned `GloVe` object includes attributes:\n", 88 | "- `stoi` _string-to-index_ returns a dictionary of words to indexes\n", 89 | "- `itos` _index-to-string_ returns an array of words by index\n", 90 | "- `vectors` returns the actual vectors. To get a word vector get the index to get the vector:" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 3, 96 | "metadata": { 97 | "collapsed": true, 98 | "scrolled": true 99 | }, 100 | "outputs": [], 101 | "source": [ 102 | "def get_word(word):\n", 103 | " return glove.vectors[glove.stoi[word]]" 104 | ] 105 | }, 106 | { 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "## Finding closest vectors\n", 111 | "\n", 112 | "Going from word → vector is easy enough, but to go from vector → word takes more work. Here I'm (naively) calculating the distance for each word in the vocabulary, and sorting based on that distance:\n", 113 | "\n", 114 | "Anyone with a suggestion for optimizing this, please let me know!" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 4, 120 | "metadata": { 121 | "collapsed": true 122 | }, 123 | "outputs": [], 124 | "source": [ 125 | "def closest(vec, n=10):\n", 126 | " \"\"\"\n", 127 | " Find the closest words for a given vector\n", 128 | " \"\"\"\n", 129 | " all_dists = [(w, torch.dist(vec, get_word(w))) for w in glove.itos]\n", 130 | " return sorted(all_dists, key=lambda t: t[1])[:n]" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "This will return a list of `(word, distance)` tuple pairs. Here's a helper function to print that list:" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 5, 143 | "metadata": { 144 | "collapsed": true 145 | }, 146 | "outputs": [], 147 | "source": [ 148 | "def print_tuples(tuples):\n", 149 | " for tuple in tuples:\n", 150 | " print('(%.4f) %s' % (tuple[1], tuple[0]))" 151 | ] 152 | }, 153 | { 154 | "cell_type": "markdown", 155 | "metadata": {}, 156 | "source": [ 157 | "Now using a known word vector we can see which other vectors are closest:" 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "execution_count": 6, 163 | "metadata": {}, 164 | "outputs": [ 165 | { 166 | "name": "stdout", 167 | "output_type": "stream", 168 | "text": [ 169 | "(0.0000) google\n", 170 | "(3.0772) yahoo\n", 171 | "(3.8836) microsoft\n", 172 | "(4.1048) web\n", 173 | "(4.1082) aol\n", 174 | "(4.1165) facebook\n", 175 | "(4.3917) ebay\n", 176 | "(4.4122) msn\n", 177 | "(4.4540) internet\n", 178 | "(4.4651) netscape\n" 179 | ] 180 | } 181 | ], 182 | "source": [ 183 | "print_tuples(closest(get_word('google')))" 184 | ] 185 | }, 186 | { 187 | "cell_type": "markdown", 188 | "metadata": {}, 189 | "source": [ 190 | "## Word analogies with vector arithmetic\n", 191 | "\n", 192 | "The most interesting feature of a well-trained word vector space is that certain semantic relationships (beyond just close-ness of words) can be captured with regular vector arithmetic. \n", 193 | "\n", 194 | "![](https://i.imgur.com/d0KuM5x.png)\n", 195 | "\n", 196 | "(image borrowed from [a slide from Omer Levy and Yoav Goldberg](https://levyomer.wordpress.com/2014/04/25/linguistic-regularities-in-sparse-and-explicit-word-representations/))" 197 | ] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": 6, 202 | "metadata": { 203 | "collapsed": false 204 | }, 205 | "outputs": [], 206 | "source": [ 207 | "# In the form w1 : w2 :: w3 : ?\n", 208 | "def analogy(w1, w2, w3, n=5, filter_given=True):\n", 209 | " print('\\n[%s : %s :: %s : ?]' % (w1, w2, w3))\n", 210 | " \n", 211 | " # w2 - w1 + w3 = w4\n", 212 | " closest_words = closest(get_word(w2) - get_word(w1) + get_word(w3))\n", 213 | " \n", 214 | " # Optionally filter out given words\n", 215 | " if filter_given:\n", 216 | " closest_words = [t for t in closest_words if t[0] not in [w1, w2, w3]]\n", 217 | " \n", 218 | " print_tuples(closest_words[:n])" 219 | ] 220 | }, 221 | { 222 | "cell_type": "markdown", 223 | "metadata": {}, 224 | "source": [ 225 | "The classic example:" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 7, 231 | "metadata": { 232 | "collapsed": false 233 | }, 234 | "outputs": [ 235 | { 236 | "name": "stdout", 237 | "output_type": "stream", 238 | "text": [ 239 | "\n", 240 | "[king : man :: queen : ?]\n", 241 | "(4.0811) woman\n", 242 | "(4.6916) girl\n", 243 | "(5.2703) she\n", 244 | "(5.2788) teenager\n", 245 | "(5.3084) boy\n" 246 | ] 247 | } 248 | ], 249 | "source": [ 250 | "analogy('king', 'man', 'queen')" 251 | ] 252 | }, 253 | { 254 | "cell_type": "markdown", 255 | "metadata": {}, 256 | "source": [ 257 | "Now let's explore the word space and see what stereotypes we can uncover:" 258 | ] 259 | }, 260 | { 261 | "cell_type": "code", 262 | "execution_count": 8, 263 | "metadata": { 264 | "collapsed": false, 265 | "scrolled": false 266 | }, 267 | "outputs": [ 268 | { 269 | "name": "stdout", 270 | "output_type": "stream", 271 | "text": [ 272 | "\n", 273 | "[man : actor :: woman : ?]\n", 274 | "(2.8133) actress\n", 275 | "(5.0039) comedian\n", 276 | "(5.1399) actresses\n", 277 | "(5.2773) starred\n", 278 | "(5.3085) screenwriter\n", 279 | "\n", 280 | "[cat : kitten :: dog : ?]\n", 281 | "(3.8146) puppy\n", 282 | "(4.2944) rottweiler\n", 283 | "(4.5888) puppies\n", 284 | "(4.6086) pooch\n", 285 | "(4.6520) pug\n", 286 | "\n", 287 | "[dog : puppy :: cat : ?]\n", 288 | "(3.8146) kitten\n", 289 | "(4.0255) puppies\n", 290 | "(4.1575) kittens\n", 291 | "(4.1882) pterodactyl\n", 292 | "(4.1945) scaredy\n", 293 | "\n", 294 | "[russia : moscow :: france : ?]\n", 295 | "(3.2697) paris\n", 296 | "(4.6857) french\n", 297 | "(4.7085) lyon\n", 298 | "(4.9087) strasbourg\n", 299 | "(5.0362) marseille\n", 300 | "\n", 301 | "[obama : president :: trump : ?]\n", 302 | "(6.4302) executive\n", 303 | "(6.5149) founder\n", 304 | "(6.6997) ceo\n", 305 | "(6.7524) hilton\n", 306 | "(6.7729) walt\n", 307 | "\n", 308 | "[rich : mansion :: poor : ?]\n", 309 | "(5.8262) residence\n", 310 | "(5.9444) riverside\n", 311 | "(6.0283) hillside\n", 312 | "(6.0328) abandoned\n", 313 | "(6.0681) bungalow\n", 314 | "\n", 315 | "[elvis : rock :: eminem : ?]\n", 316 | "(5.6597) rap\n", 317 | "(6.2057) rappers\n", 318 | "(6.2161) rapper\n", 319 | "(6.2444) punk\n", 320 | "(6.2690) hop\n", 321 | "\n", 322 | "[paper : newspaper :: screen : ?]\n", 323 | "(4.7810) tv\n", 324 | "(5.1049) television\n", 325 | "(5.3818) cinema\n", 326 | "(5.5524) feature\n", 327 | "(5.5646) shows\n", 328 | "\n", 329 | "[monet : paint :: michelangelo : ?]\n", 330 | "(6.0782) plaster\n", 331 | "(6.3768) mold\n", 332 | "(6.3922) tile\n", 333 | "(6.5819) marble\n", 334 | "(6.6524) image\n", 335 | "\n", 336 | "[beer : barley :: wine : ?]\n", 337 | "(5.6021) grape\n", 338 | "(5.6760) beans\n", 339 | "(5.8174) grapes\n", 340 | "(5.9035) lentils\n", 341 | "(5.9454) figs\n", 342 | "\n", 343 | "[earth : moon :: sun : ?]\n", 344 | "(6.2294) lee\n", 345 | "(6.4125) kang\n", 346 | "(6.4644) tan\n", 347 | "(6.4757) yang\n", 348 | "(6.4853) lin\n", 349 | "\n", 350 | "[house : roof :: castle : ?]\n", 351 | "(6.2919) stonework\n", 352 | "(6.3779) masonry\n", 353 | "(6.4773) canopy\n", 354 | "(6.4954) fortress\n", 355 | "(6.5259) battlements\n", 356 | "\n", 357 | "[building : architect :: software : ?]\n", 358 | "(5.8369) programmer\n", 359 | "(6.8881) entrepreneur\n", 360 | "(6.9240) inventor\n", 361 | "(6.9730) developer\n", 362 | "(6.9949) innovator\n", 363 | "\n", 364 | "[boston : bruins :: phoenix : ?]\n", 365 | "(3.8546) suns\n", 366 | "(4.1968) mavericks\n", 367 | "(4.6126) coyotes\n", 368 | "(4.6894) mavs\n", 369 | "(4.6971) knicks\n", 370 | "\n", 371 | "[good : heaven :: bad : ?]\n", 372 | "(4.3959) hell\n", 373 | "(5.2864) ghosts\n", 374 | "(5.2898) hades\n", 375 | "(5.3414) madness\n", 376 | "(5.3520) purgatory\n", 377 | "\n", 378 | "[jordan : basketball :: woods : ?]\n", 379 | "(5.8607) golf\n", 380 | "(6.4110) golfers\n", 381 | "(6.4418) tournament\n", 382 | "(6.4592) tennis\n", 383 | "(6.6560) collegiate\n" 384 | ] 385 | } 386 | ], 387 | "source": [ 388 | "analogy('man', 'actor', 'woman')\n", 389 | "analogy('cat', 'kitten', 'dog')\n", 390 | "analogy('dog', 'puppy', 'cat')\n", 391 | "analogy('russia', 'moscow', 'france')\n", 392 | "analogy('obama', 'president', 'trump')\n", 393 | "analogy('rich', 'mansion', 'poor')\n", 394 | "analogy('elvis', 'rock', 'eminem')\n", 395 | "analogy('paper', 'newspaper', 'screen')\n", 396 | "analogy('monet', 'paint', 'michelangelo')\n", 397 | "analogy('beer', 'barley', 'wine')\n", 398 | "analogy('earth', 'moon', 'sun') # Interesting failure mode\n", 399 | "analogy('house', 'roof', 'castle')\n", 400 | "analogy('building', 'architect', 'software')\n", 401 | "analogy('boston', 'bruins', 'phoenix')\n", 402 | "analogy('good', 'heaven', 'bad')\n", 403 | "analogy('jordan', 'basketball', 'woods')" 404 | ] 405 | } 406 | ], 407 | "metadata": { 408 | "anaconda-cloud": {}, 409 | "kernelspec": { 410 | "display_name": "Python [default]", 411 | "language": "python", 412 | "name": "python3" 413 | }, 414 | "language_info": { 415 | "codemirror_mode": { 416 | "name": "ipython", 417 | "version": 3 418 | }, 419 | "file_extension": ".py", 420 | "mimetype": "text/x-python", 421 | "name": "python", 422 | "nbconvert_exporter": "python", 423 | "pygments_lexer": "ipython3", 424 | "version": "3.5.2" 425 | } 426 | }, 427 | "nbformat": 4, 428 | "nbformat_minor": 2 429 | } 430 | -------------------------------------------------------------------------------- /reinforce-gridworld/helpers.py: -------------------------------------------------------------------------------- 1 | def interpolate(i, v_from, v_to, over): 2 | return (v_from - v_to) * max(0, (1 - i / over)) + v_to 3 | 4 | class SlidingAverage: 5 | def __init__(self, name, steps=100): 6 | self.name = name 7 | self.steps = steps 8 | self.t = 0 9 | self.ns = [] 10 | self.avgs = [] 11 | 12 | def add(self, n): 13 | self.ns.append(n) 14 | if len(self.ns) > self.steps: 15 | self.ns.pop(0) 16 | self.t += 1 17 | if self.t % self.steps == 0: 18 | self.avgs.append(self.value) 19 | 20 | @property 21 | def value(self): 22 | if len(self.ns) == 0: return 0 23 | return sum(self.ns) / len(self.ns) 24 | 25 | def __str__(self): 26 | return "%s=%.4f" % (self.name, self.value) 27 | 28 | def __gt__(self, value): return self.value > value 29 | def __lt__(self, value): return self.value < value -------------------------------------------------------------------------------- /reinforce-gridworld/reinforce-gridworld.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # # Practical PyTorch: Playing GridWorld with Reinforcement Learning (Actor-Critic with REINFORCE) 4 | 5 | # ## Resources 6 | 7 | # ## Requirements 8 | 9 | import numpy as np 10 | from itertools import count 11 | import random, math 12 | 13 | import torch 14 | import torch.nn as nn 15 | import torch.nn.functional as F 16 | import torch.optim as optim 17 | import torch.autograd as autograd 18 | from torch.autograd import Variable 19 | 20 | from helpers import * 21 | 22 | # Configuration 23 | 24 | gamma = 0.9 # Discounted reward factor 25 | 26 | hidden_size = 50 27 | learning_rate = 1e-4 28 | weight_decay = 1e-5 29 | 30 | log_every = 1000 31 | render_every = 20000 32 | 33 | import sconce 34 | job = sconce.Job('rl2', { 35 | 'gamma': gamma, 36 | 'learning_rate': learning_rate, 37 | }) 38 | job.log_every = log_every 39 | job.plot_every = 500 40 | 41 | DROP_MAX = 0.3 42 | DROP_MIN = 0.05 43 | DROP_OVER = 200000 44 | 45 | # ## The Grid World, Agent and Environment 46 | 47 | # ### The Grid 48 | 49 | MIN_PLANT_VALUE = -1 50 | MAX_PLANT_VALUE = 0.5 51 | GOAL_VALUE = 10 52 | EDGE_VALUE = -10 53 | VISIBLE_RADIUS = 1 54 | 55 | class Grid(): 56 | def __init__(self, grid_size=8, n_plants=15): 57 | self.grid_size = grid_size 58 | self.n_plants = n_plants 59 | 60 | def reset(self): 61 | padded_size = self.grid_size + 2 * VISIBLE_RADIUS 62 | self.grid = np.zeros((padded_size, padded_size)) # Padding for edges 63 | 64 | # Edges 65 | self.grid[0:VISIBLE_RADIUS, :] = EDGE_VALUE 66 | self.grid[-1*VISIBLE_RADIUS:, :] = EDGE_VALUE 67 | self.grid[:, 0:VISIBLE_RADIUS] = EDGE_VALUE 68 | self.grid[:, -1*VISIBLE_RADIUS:] = EDGE_VALUE 69 | 70 | # Randomly placed plants 71 | for i in range(self.n_plants): 72 | plant_value = random.random() * (MAX_PLANT_VALUE - MIN_PLANT_VALUE) + MIN_PLANT_VALUE 73 | ry = random.randint(0, self.grid_size-1) + VISIBLE_RADIUS 74 | rx = random.randint(0, self.grid_size-1) + VISIBLE_RADIUS 75 | self.grid[ry, rx] = plant_value 76 | 77 | # Goal in one of the corners 78 | S = VISIBLE_RADIUS 79 | E = self.grid_size + VISIBLE_RADIUS - 1 80 | gps = [(E, E), (S, E), (E, S), (S, S)] 81 | gp = gps[random.randint(0, len(gps)-1)] 82 | self.grid[gp] = GOAL_VALUE 83 | 84 | def visible(self, pos): 85 | y, x = pos 86 | return self.grid[y-VISIBLE_RADIUS:y+VISIBLE_RADIUS+1, x-VISIBLE_RADIUS:x+VISIBLE_RADIUS+1] 87 | 88 | # ### The Agent 89 | 90 | START_HEALTH = 1 91 | STEP_VALUE = -0.02 92 | 93 | class Agent: 94 | def reset(self): 95 | self.health = START_HEALTH 96 | 97 | def act(self, action): 98 | # Move according to action: 0=UP, 1=RIGHT, 2=DOWN, 3=LEFT 99 | y, x = self.pos 100 | if action == 0: y -= 1 101 | elif action == 1: x += 1 102 | elif action == 2: y += 1 103 | elif action == 3: x -= 1 104 | self.pos = (y, x) 105 | self.health += STEP_VALUE # Gradually getting hungrier 106 | 107 | # ### The Environment 108 | 109 | class Environment: 110 | def __init__(self): 111 | self.grid = Grid() 112 | self.agent = Agent() 113 | 114 | def reset(self): 115 | """Start a new episode by resetting grid and agent""" 116 | self.grid.reset() 117 | self.agent.reset() 118 | c = int(self.grid.grid_size / 2) 119 | self.agent.pos = (c, c) 120 | 121 | self.t = 0 122 | self.history = [] 123 | self.record_step() 124 | 125 | return self.visible_state 126 | 127 | def record_step(self): 128 | """Add the current state to history for display later""" 129 | grid = np.array(self.grid.grid) 130 | grid[self.agent.pos] = self.agent.health * 0.5 # Agent marker faded by health 131 | visible = np.array(self.grid.visible(self.agent.pos)) 132 | self.history.append((grid, visible, self.agent.health)) 133 | 134 | @property 135 | def visible_state(self): 136 | """Return the visible area surrounding the agent, and current agent health""" 137 | visible = self.grid.visible(self.agent.pos) 138 | y, x = self.agent.pos 139 | yp = (y - VISIBLE_RADIUS) / self.grid.grid_size 140 | xp = (x - VISIBLE_RADIUS) / self.grid.grid_size 141 | extras = [self.agent.health, yp, xp] 142 | return np.concatenate((visible.flatten(), extras), 0) 143 | 144 | def step(self, action): 145 | """Update state (grid and agent) based on an action""" 146 | self.agent.act(action) 147 | 148 | # Get reward from where agent landed, add to agent health 149 | value = self.grid.grid[self.agent.pos] 150 | self.grid.grid[self.agent.pos] = 0 151 | self.agent.health += value 152 | 153 | # Check if agent won (reached the goal) or lost (health reached 0) 154 | won = value == GOAL_VALUE 155 | lost = self.agent.health <= 0 156 | done = won or lost 157 | 158 | # Rewards at end of episode 159 | if won: 160 | reward = 1 161 | elif lost: 162 | reward = -1 163 | else: 164 | reward = 0 # Reward will only come at the end 165 | # reward = value # Try this for quicker learning 166 | 167 | # Save in history 168 | self.record_step() 169 | 170 | return self.visible_state, reward, done 171 | 172 | # ## Actor-Critic network 173 | 174 | class Policy(nn.Module): 175 | def __init__(self, hidden_size): 176 | super(Policy, self).__init__() 177 | 178 | visible_squares = (VISIBLE_RADIUS * 2 + 1) ** 2 179 | input_size = visible_squares + 1 + 2 # Plus agent health, y, x 180 | 181 | self.inp = nn.Linear(input_size, hidden_size) 182 | self.out = nn.Linear(hidden_size, 4 + 1, bias=False) # For both action and expected value 183 | 184 | def forward(self, x): 185 | x = x.view(1, -1) 186 | x = F.tanh(x) # Squash inputs 187 | x = F.relu(self.inp(x)) 188 | x = self.out(x) 189 | 190 | # Split last five outputs into scores and value 191 | scores = x[:,:4] 192 | value = x[:,4] 193 | return scores, value 194 | 195 | # ## Selecting actions 196 | 197 | def select_action(e, state): 198 | drop = interpolate(e, DROP_MAX, DROP_MIN, DROP_OVER) 199 | 200 | state = Variable(torch.from_numpy(state).float()) 201 | scores, value = policy(state) # Forward state through network 202 | scores = F.dropout(scores, drop, True) # Dropout for exploration 203 | scores = F.softmax(scores) 204 | action = scores.multinomial() # Sample an action 205 | 206 | return action, value 207 | 208 | # ## Playing through an episode 209 | 210 | def run_episode(e): 211 | state = env.reset() 212 | actions = [] 213 | values = [] 214 | rewards = [] 215 | done = False 216 | 217 | while not done: 218 | action, value = select_action(e, state) 219 | state, reward, done = env.step(action.data[0, 0]) 220 | actions.append(action) 221 | values.append(value) 222 | rewards.append(reward) 223 | 224 | return actions, values, rewards 225 | 226 | # ## Using REINFORCE with a value baseline 227 | 228 | mse = nn.MSELoss() 229 | 230 | def finish_episode(e, actions, values, rewards): 231 | 232 | # Calculate discounted rewards, going backwards from end 233 | discounted_rewards = [] 234 | R = 0 235 | for r in rewards[::-1]: 236 | R = r + gamma * R 237 | discounted_rewards.insert(0, R) 238 | discounted_rewards = torch.Tensor(discounted_rewards) 239 | 240 | # Use REINFORCE on chosen actions and associated discounted rewards 241 | value_loss = 0 242 | for action, value, reward in zip(actions, values, discounted_rewards): 243 | reward_diff = reward - value.data[0] # Treat critic value as baseline 244 | action.reinforce(reward_diff) # Try to perform better than baseline 245 | value_loss += mse(value, Variable(torch.Tensor([reward]))) # Compare with actual reward 246 | 247 | # Backpropagate 248 | optimizer.zero_grad() 249 | nodes = [value_loss] + actions 250 | gradients = [torch.ones(1)] + [None for _ in actions] # No gradients for reinforced values 251 | autograd.backward(nodes, gradients) 252 | optimizer.step() 253 | 254 | return discounted_rewards, value_loss 255 | 256 | env = Environment() 257 | policy = Policy(hidden_size=hidden_size) 258 | optimizer = optim.Adam(policy.parameters(), lr=learning_rate, weight_decay=weight_decay) 259 | 260 | reward_avg = SlidingAverage('reward avg', steps=log_every) 261 | value_loss_avg = SlidingAverage('value loss avg', steps=log_every) 262 | 263 | e = 0 264 | 265 | while reward_avg < 1.0: 266 | actions, values, rewards = run_episode(e) 267 | final_reward = rewards[-1] 268 | 269 | discounted_rewards, value_loss = finish_episode(e, actions, values, rewards) 270 | 271 | job.record(e, final_reward) # REMOVE 272 | reward_avg.add(final_reward) 273 | value_loss_avg.add(value_loss.data[0]) 274 | 275 | if e % log_every == 0: 276 | print('[epoch=%d]' % e, reward_avg, value_loss_avg) 277 | 278 | e += 1 279 | 280 | 281 | -------------------------------------------------------------------------------- /seq2seq-translation/images/attention-decoder-network.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | 3 | // Main styles 4 | nodesep=0.3; ranksep=0.15; 5 | 6 | node [shape=rect, fillcolor=darkorange, color=white, style=filled, fontsize=11, fontname="arial", height=0.2]; 7 | edge [color=gray, arrowsize=0.5]; 8 | 9 | // Layout 10 | {rank=same;input;prev_hidden;encoder_outputs} 11 | 12 | 13 | input -> embedding; 14 | embedding -> dropout; 15 | dropout -> embedded; 16 | 17 | embedded -> attn; 18 | prev_hidden -> attn; 19 | attn -> attn_softmax; 20 | attn_softmax -> attn_weights; 21 | attn_weights -> bmm; 22 | encoder_outputs -> bmm; 23 | bmm -> attn_applied; 24 | attn_applied -> attn_combine; 25 | embedded -> attn_combine; 26 | 27 | attn_combine -> relu -> gru; 28 | prev_hidden -> gru; 29 | gru -> out; 30 | gru -> hidden; 31 | 32 | out -> softmax; 33 | softmax -> output; 34 | 35 | {rank=same;output;hidden} 36 | 37 | // Layer nodes 38 | embedding [fillcolor=dodgerblue, fontcolor=white]; 39 | attn [fillcolor=dodgerblue, fontcolor=white]; 40 | attn_combine [fillcolor=dodgerblue, fontcolor=white]; 41 | bmm [fillcolor=dodgerblue, fontcolor=white]; 42 | gru [fillcolor=dodgerblue, fontcolor=white]; 43 | out [fillcolor=dodgerblue, fontcolor=white]; 44 | 45 | // Function nodes 46 | dropout [fillcolor=palegreen]; 47 | relu [fillcolor=palegreen]; 48 | softmax [fillcolor=palegreen]; 49 | attn_softmax [fillcolor=palegreen]; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /seq2seq-translation/images/attention-decoder-network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/attention-decoder-network.png -------------------------------------------------------------------------------- /seq2seq-translation/images/decoder-network.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | 3 | // Main styles 4 | nodesep=0.3; ranksep=0.15; 5 | 6 | node [shape=rect, fillcolor=darkorange, color=white, style=filled, fontsize=11, fontname="arial", height=0.2]; 7 | edge [color=gray, arrowsize=0.5]; 8 | 9 | // Layout 10 | {rank=same;input;prev_hidden} 11 | 12 | input -> embedding; 13 | embedding -> relu; 14 | relu -> gru; 15 | 16 | prev_hidden -> gru; 17 | gru -> out; 18 | gru -> hidden; 19 | 20 | out -> softmax; 21 | softmax -> output; 22 | 23 | {rank=same;output;hidden} 24 | 25 | // Layer nodes 26 | embedding [fillcolor=dodgerblue, fontcolor=white]; 27 | gru [fillcolor=dodgerblue, fontcolor=white]; 28 | out [fillcolor=dodgerblue, fontcolor=white]; 29 | 30 | // Function nodes 31 | relu [fillcolor=palegreen]; 32 | softmax [fillcolor=palegreen]; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /seq2seq-translation/images/decoder-network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/decoder-network.png -------------------------------------------------------------------------------- /seq2seq-translation/images/decoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/decoder.png -------------------------------------------------------------------------------- /seq2seq-translation/images/decoder@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/decoder@2x.png -------------------------------------------------------------------------------- /seq2seq-translation/images/encoder-network.dot: -------------------------------------------------------------------------------- 1 | digraph G { 2 | 3 | // Main styles 4 | nodesep=0.3; ranksep=0.15; 5 | 6 | node [shape=rect, fillcolor=darkorange, color=white, style=filled, fontsize=11, fontname="arial", height=0.2]; 7 | edge [color=gray, arrowsize=0.5]; 8 | 9 | // Layout 10 | {rank=same;input;prev_hidden} 11 | 12 | input -> embedding; 13 | embedding -> embedded; 14 | embedded -> gru; 15 | prev_hidden -> gru; 16 | gru -> output; 17 | gru -> hidden; 18 | 19 | embedding [fillcolor=dodgerblue, fontcolor=white]; 20 | gru [fillcolor=dodgerblue, fontcolor=white]; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /seq2seq-translation/images/encoder-network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/encoder-network.png -------------------------------------------------------------------------------- /seq2seq-translation/images/seq2seq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/seq2seq.png -------------------------------------------------------------------------------- /seq2seq-translation/images/seq2seq@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/seq2seq@2x.png -------------------------------------------------------------------------------- /seq2seq-translation/images/word-encoding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/word-encoding.png -------------------------------------------------------------------------------- /seq2seq-translation/images/word-encoding@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spro/practical-pytorch/c520c52e68e945d88fff563dba1c028b6ec0197b/seq2seq-translation/images/word-encoding@2x.png -------------------------------------------------------------------------------- /seq2seq-translation/masked_cross_entropy.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.nn import functional 3 | from torch.autograd import Variable 4 | 5 | def sequence_mask(sequence_length, max_len=None): 6 | if max_len is None: 7 | max_len = sequence_length.data.max() 8 | batch_size = sequence_length.size(0) 9 | seq_range = torch.range(0, max_len - 1).long() 10 | seq_range_expand = seq_range.unsqueeze(0).expand(batch_size, max_len) 11 | seq_range_expand = Variable(seq_range_expand) 12 | if sequence_length.is_cuda: 13 | seq_range_expand = seq_range_expand.cuda() 14 | seq_length_expand = (sequence_length.unsqueeze(1) 15 | .expand_as(seq_range_expand)) 16 | return seq_range_expand < seq_length_expand 17 | 18 | 19 | def masked_cross_entropy(logits, target, length): 20 | length = Variable(torch.LongTensor(length)).cuda() 21 | 22 | """ 23 | Args: 24 | logits: A Variable containing a FloatTensor of size 25 | (batch, max_len, num_classes) which contains the 26 | unnormalized probability for each class. 27 | target: A Variable containing a LongTensor of size 28 | (batch, max_len) which contains the index of the true 29 | class for each corresponding step. 30 | length: A Variable containing a LongTensor of size (batch,) 31 | which contains the length of each data in a batch. 32 | 33 | Returns: 34 | loss: An average loss value masked by the length. 35 | """ 36 | 37 | # logits_flat: (batch * max_len, num_classes) 38 | logits_flat = logits.view(-1, logits.size(-1)) 39 | # log_probs_flat: (batch * max_len, num_classes) 40 | log_probs_flat = functional.log_softmax(logits_flat) 41 | # target_flat: (batch * max_len, 1) 42 | target_flat = target.view(-1, 1) 43 | # losses_flat: (batch * max_len, 1) 44 | losses_flat = -torch.gather(log_probs_flat, dim=1, index=target_flat) 45 | # losses: (batch, max_len) 46 | losses = losses_flat.view(*target.size()) 47 | # mask: (batch, max_len) 48 | mask = sequence_mask(sequence_length=length, max_len=target.size(1)) 49 | losses = losses * mask.float() 50 | loss = losses.sum() / length.float().sum() 51 | return loss 52 | -------------------------------------------------------------------------------- /seq2seq-translation/seq2seq-translation-batched.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | import unicodedata 4 | import string 5 | import re 6 | import random 7 | import time 8 | import datetime 9 | import math 10 | import socket 11 | hostname = socket.gethostname() 12 | 13 | import torch 14 | import torch.nn as nn 15 | from torch.autograd import Variable 16 | from torch import optim 17 | import torch.nn.functional as F 18 | from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence 19 | 20 | import matplotlib.pyplot as plt 21 | import matplotlib.ticker as ticker 22 | matplotlib.use('Agg') 23 | import numpy as np 24 | 25 | import io 26 | import torchvision 27 | from PIL import Image 28 | import visdom 29 | vis = visdom.Visdom() 30 | 31 | USE_CUDA = True 32 | 33 | SOS_token = 0 34 | EOS_token = 1 35 | 36 | # Configure models 37 | attn_model = 'dot' 38 | hidden_size = 500 39 | n_layers = 2 40 | dropout = 0.1 41 | batch_size = 100 42 | batch_size = 50 43 | 44 | # Configure training/optimization 45 | clip = 50.0 46 | teacher_forcing_ratio = 0.5 47 | learning_rate = 0.0001 48 | decoder_learning_ratio = 5.0 49 | n_epochs = 50000 50 | epoch = 0 51 | plot_every = 20 52 | print_every = 100 53 | evaluate_every = 1000 54 | 55 | # Initialize models 56 | encoder = EncoderRNN(input_lang.n_words, hidden_size, n_layers, dropout=dropout) 57 | decoder = LuongAttnDecoderRNN(attn_model, hidden_size, output_lang.n_words, n_layers, dropout=dropout) 58 | 59 | # Initialize optimizers and criterion 60 | encoder_optimizer = optim.Adam(encoder.parameters(), lr=learning_rate) 61 | decoder_optimizer = optim.Adam(decoder.parameters(), lr=learning_rate * decoder_learning_ratio) 62 | 63 | # Move models to GPU 64 | if USE_CUDA: 65 | encoder.cuda() 66 | decoder.cuda() 67 | 68 | # Keep track of time elapsed and running averages 69 | start = time.time() 70 | plot_losses = [] 71 | print_loss_total = 0 # Reset every print_every 72 | plot_loss_total = 0 # Reset every plot_every 73 | 74 | # ---------------------------------------------------------------------------------------- 75 | 76 | class Lang: 77 | def __init__(self, name): 78 | self.name = name 79 | self.word2index = {} 80 | self.word2count = {} 81 | self.index2word = {0: "SOS", 1: "EOS"} 82 | self.n_words = 2 # Count SOS and EOS 83 | 84 | def index_words(self, sentence): 85 | for word in sentence.split(' '): 86 | self.index_word(word) 87 | 88 | def index_word(self, word): 89 | if word not in self.word2index: 90 | self.word2index[word] = self.n_words 91 | self.word2count[word] = 1 92 | self.index2word[self.n_words] = word 93 | self.n_words += 1 94 | else: 95 | self.word2count[word] += 1 96 | 97 | def trim(self, min_count=3): 98 | keep = [] 99 | 100 | for k, v in self.word2count.items(): 101 | if v >= min_count: 102 | keep.append(k) 103 | 104 | print('total', len(self.word2index)) 105 | print('keep', len(keep)) 106 | print('keep %', len(keep) / len(self.word2index)) 107 | 108 | self.word2index = {} 109 | self.word2count = {} 110 | self.index2word = {0: "SOS", 1: "EOS"} 111 | self.n_words = 2 # Count SOS and EOS 112 | 113 | for word in keep: 114 | self.index_word(word) 115 | 116 | # Turn a Unicode string to plain ASCII, thanks to http://stackoverflow.com/a/518232/2809427 117 | def unicode_to_ascii(s): 118 | return ''.join( 119 | c for c in unicodedata.normalize('NFD', s) 120 | if unicodedata.category(c) != 'Mn' 121 | ) 122 | 123 | # Lowercase, trim, and remove non-letter characters 124 | def normalize_string(s): 125 | s = unicode_to_ascii(s.lower().strip()) 126 | s = re.sub(r"([.!?])", r" \1", s) 127 | s = re.sub(r"[^a-zA-Z.!?]+", r" ", s) 128 | return s 129 | 130 | def read_langs(lang1, lang2, reverse=False): 131 | print("Reading lines...") 132 | 133 | # Read the file and split into lines 134 | # filename = '../data/%s-%s.txt' % (lang1, lang2) 135 | filename = '../%s-%s.txt' % (lang1, lang2) 136 | lines = open(filename).read().strip().split('\n') 137 | 138 | # Split every line into pairs and normalize 139 | pairs = [[normalize_string(s) for s in l.split('\t')] for l in lines] 140 | 141 | # Reverse pairs, make Lang instances 142 | if reverse: 143 | pairs = [list(reversed(p)) for p in pairs] 144 | input_lang = Lang(lang2) 145 | output_lang = Lang(lang1) 146 | else: 147 | input_lang = Lang(lang1) 148 | output_lang = Lang(lang2) 149 | 150 | return input_lang, output_lang, pairs 151 | 152 | MIN_LENGTH = 5 153 | MAX_LENGTH = 20 154 | 155 | good_prefixes = ( 156 | "i ", "he ", "she ", "you ", "they ", "we " 157 | ) 158 | 159 | def filter_pair(p): 160 | return len(p[0].split(' ')) <= MAX_LENGTH and len(p[1].split(' ')) <= MAX_LENGTH and len(p[0].split(' ')) >= MIN_LENGTH and len(p[1].split(' ')) >= MIN_LENGTH # and \ 161 | # p[1].startswith(good_prefixes) 162 | 163 | def filter_pairs(pairs): 164 | return [pair for pair in pairs if filter_pair(pair)] 165 | 166 | def prepare_data(lang1_name, lang2_name, reverse=False): 167 | input_lang, output_lang, pairs = read_langs(lang1_name, lang2_name, reverse) 168 | print("Read %s sentence pairs" % len(pairs)) 169 | 170 | pairs = filter_pairs(pairs) 171 | print("Trimmed to %s sentence pairs" % len(pairs)) 172 | 173 | print("Indexing words...") 174 | for pair in pairs: 175 | input_lang.index_words(pair[0]) 176 | output_lang.index_words(pair[1]) 177 | 178 | return input_lang, output_lang, pairs 179 | 180 | input_lang, output_lang, pairs = prepare_data('eng', 'fra', True) 181 | input_lang.trim() 182 | output_lang.trim() 183 | 184 | keep_pairs = [] 185 | 186 | for pair in pairs: 187 | keep_input = True 188 | keep_output = True 189 | 190 | for word in pair[0].split(' '): 191 | if word not in input_lang.word2index: 192 | keep_input = False 193 | break 194 | 195 | for word in pair[1].split(' '): 196 | if word not in output_lang.word2index: 197 | keep_output = False 198 | break 199 | 200 | if keep_input and keep_output: 201 | keep_pairs.append(pair) 202 | 203 | print(len(pairs)) 204 | print(len(keep_pairs)) 205 | print(len(keep_pairs) / len(pairs)) 206 | pairs = keep_pairs 207 | 208 | # Return a list of indexes, one for each word in the sentence 209 | def indexes_from_sentence(lang, sentence): 210 | return [lang.word2index[word] for word in sentence.split(' ')] + [EOS_token] 211 | 212 | def pad_seq(seq, max_length): 213 | seq += [0 for i in range(max_length - len(seq))] 214 | return seq 215 | 216 | def random_batch(batch_size=3): 217 | input_seqs = [] 218 | target_seqs = [] 219 | 220 | # Choose random pairs 221 | for i in range(batch_size): 222 | pair = random.choice(pairs) 223 | input_seqs.append(indexes_from_sentence(input_lang, pair[0])) 224 | target_seqs.append(indexes_from_sentence(output_lang, pair[1])) 225 | 226 | # Zip into pairs, sort by length (descending), unzip 227 | seq_pairs = sorted(zip(input_seqs, target_seqs), key=lambda p: len(p[0]), reverse=True) 228 | input_seqs, target_seqs = zip(*seq_pairs) 229 | 230 | # For input and target sequences, get array of lengths and pad with 0s to max length 231 | input_lengths = [len(s) for s in input_seqs] 232 | input_padded = [pad_seq(s, max(input_lengths)) for s in input_seqs] 233 | target_lengths = [len(s) for s in target_seqs] 234 | target_padded = [pad_seq(s, max(target_lengths)) for s in target_seqs] 235 | 236 | # Turn padded arrays into (batch x seq) tensors, transpose into (seq x batch) 237 | input_var = Variable(torch.LongTensor(input_padded)).transpose(0, 1) 238 | target_var = Variable(torch.LongTensor(target_padded)).transpose(0, 1) 239 | 240 | if USE_CUDA: 241 | input_var = input_var.cuda() 242 | target_var = target_var.cuda() 243 | 244 | return input_var, input_lengths, target_var, target_lengths 245 | 246 | random_batch() 247 | 248 | class EncoderRNN(nn.Module): 249 | def __init__(self, input_size, hidden_size, n_layers=1, dropout=0.1): 250 | super(EncoderRNN, self).__init__() 251 | 252 | self.input_size = input_size 253 | self.hidden_size = hidden_size 254 | self.n_layers = n_layers 255 | self.dropout = dropout 256 | 257 | self.embedding = nn.Embedding(input_size, hidden_size) 258 | self.gru = nn.GRU(hidden_size, hidden_size, n_layers, dropout=self.dropout) 259 | 260 | def forward(self, input_seqs, input_lengths, hidden=None): 261 | embedded = self.embedding(input_seqs) 262 | packed = torch.nn.utils.rnn.pack_padded_sequence(embedded, input_lengths) 263 | output, hidden = self.gru(packed, hidden) 264 | output, _ = torch.nn.utils.rnn.pad_packed_sequence(output) # unpack (back to padded) 265 | return output, hidden 266 | 267 | class Attn(nn.Module): 268 | def __init__(self, method, hidden_size): 269 | super(Attn, self).__init__() 270 | 271 | self.method = method 272 | self.hidden_size = hidden_size 273 | 274 | if self.method == 'general': 275 | self.attn = nn.Linear(self.hidden_size, hidden_size) 276 | 277 | elif self.method == 'concat': 278 | self.attn = nn.Linear(self.hidden_size * 2, hidden_size) 279 | self.v = nn.Parameter(torch.FloatTensor(1, hidden_size)) 280 | 281 | def forward(self, hidden, encoder_outputs): 282 | seq_len = encoder_outputs.size(0) 283 | batch_size = encoder_outputs.size(1) 284 | # print('[attn] seq len', seq_len) 285 | # print('[attn] encoder_outputs', encoder_outputs.size()) # S x B x N 286 | # print('[attn] hidden', hidden.size()) # S=1 x B x N 287 | 288 | # Create variable to store attention energies 289 | attn_energies = Variable(torch.zeros(batch_size, seq_len)) # B x S 290 | # print('[attn] attn_energies', attn_energies.size()) 291 | 292 | if USE_CUDA: 293 | attn_energies = attn_energies.cuda() 294 | 295 | # For each batch of encoder outputs 296 | for b in range(batch_size): 297 | # Calculate energy for each encoder output 298 | for i in range(seq_len): 299 | attn_energies[b, i] = self.score(hidden[:, b], encoder_outputs[i, b].unsqueeze(0)) 300 | 301 | # Normalize energies to weights in range 0 to 1, resize to 1 x B x S 302 | # print('[attn] attn_energies', attn_energies.size()) 303 | return F.softmax(attn_energies).unsqueeze(1) 304 | 305 | def score(self, hidden, encoder_output): 306 | 307 | if self.method == 'dot': 308 | energy = hidden.dot(encoder_output) 309 | return energy 310 | 311 | elif self.method == 'general': 312 | energy = self.attn(encoder_output) 313 | energy = hidden.dot(energy) 314 | return energy 315 | 316 | elif self.method == 'concat': 317 | energy = self.attn(torch.cat((hidden, encoder_output), 1)) 318 | energy = self.v.dot(energy) 319 | return energy 320 | 321 | rnn_output = Variable(torch.zeros(1, 2, 10)) 322 | encoder_outputs = Variable(torch.zeros(3, 2, 10)) 323 | attn = Attn('concat', 10) 324 | attn(rnn_output, encoder_outputs) 325 | 326 | attn_weights = torch.zeros(2, 1, 3) 327 | print('attn_weights', attn_weights.size()) 328 | encoder_outputs = torch.zeros(3, 2, 10) 329 | print('encoder_outputs', encoder_outputs.size()) 330 | # B x N x M 331 | # , B x M x P 332 | # -> B x N x P 333 | context = attn_weights.bmm(encoder_outputs.transpose(0, 1)) 334 | context = context.transpose(0, 1) 335 | print('context', context.size()) 336 | 337 | class LuongAttnDecoderRNN(nn.Module): 338 | def __init__(self, attn_model, hidden_size, output_size, n_layers=1, dropout=0.1): 339 | super(LuongAttnDecoderRNN, self).__init__() 340 | 341 | # Keep for reference 342 | self.attn_model = attn_model 343 | self.hidden_size = hidden_size 344 | self.output_size = output_size 345 | self.n_layers = n_layers 346 | self.dropout = dropout 347 | 348 | # Define layers 349 | self.embedding = nn.Embedding(output_size, hidden_size) 350 | self.embedding_dropout = nn.Dropout(dropout) 351 | self.gru = nn.GRU(hidden_size, hidden_size, n_layers, dropout=dropout) 352 | self.concat = nn.Linear(hidden_size * 2, hidden_size) 353 | self.out = nn.Linear(hidden_size, output_size) 354 | 355 | # Choose attention model 356 | if attn_model != 'none': 357 | self.attn = Attn(attn_model, hidden_size) 358 | 359 | def forward(self, input_seq, last_context, last_hidden, encoder_outputs): 360 | # Note: we run this one step at a time (in order to do teacher forcing) 361 | 362 | # Get the embedding of the current input word (last output word) 363 | batch_size = input_seq.size(0) 364 | # print('[decoder] input_seq', input_seq.size()) # batch_size x 1 365 | embedded = self.embedding(input_seq) 366 | embedded = self.embedding_dropout(embedded) 367 | embedded = embedded.view(1, batch_size, hidden_size) # S=1 x B x N 368 | # print('[decoder] word_embedded', embedded.size()) 369 | 370 | # Get current hidden state from input word and last hidden state 371 | # print('[decoder] last_hidden', last_hidden.size()) 372 | rnn_output, hidden = self.gru(embedded, last_hidden) 373 | # print('[decoder] rnn_output', rnn_output.size()) 374 | 375 | # Calculate attention from current RNN state and all encoder outputs; 376 | # apply to encoder outputs to get weighted average 377 | attn_weights = self.attn(rnn_output, encoder_outputs) 378 | # print('[decoder] attn_weights', attn_weights.size()) 379 | # print('[decoder] encoder_outputs', encoder_outputs.size()) 380 | context = attn_weights.bmm(encoder_outputs.transpose(0, 1)) # B x S=1 x N 381 | # print('[decoder] context', context.size()) 382 | 383 | # Attentional vector using the RNN hidden state and context vector 384 | # concatenated together (Luong eq. 5) 385 | rnn_output = rnn_output.squeeze(0) # S=1 x B x N -> B x N 386 | context = context.squeeze(1) # B x S=1 x N -> B x N 387 | # print('[decoder] rnn_output', rnn_output.size()) 388 | # print('[decoder] context', context.size()) 389 | concat_input = torch.cat((rnn_output, context), 1) 390 | concat_output = F.tanh(self.concat(concat_input)) 391 | 392 | # Finally predict next token (Luong eq. 6) 393 | # output = F.log_softmax(self.out(concat_output)) 394 | output = self.out(concat_output) 395 | 396 | # Return final output, hidden state, and attention weights (for visualization) 397 | return output, context, hidden, attn_weights 398 | 399 | 400 | # ## Testing the models 401 | # 402 | # To make sure the encoder and decoder are working (and working together) we'll do a quick test. 403 | # 404 | # First by creating and padding a batch of sequences: 405 | 406 | # In[394]: 407 | 408 | # Input as batch of sequences of word indexes 409 | batch_size = 2 410 | input_batches, input_lengths, target_batches, target_lengths = random_batch(batch_size) 411 | print('input_batches', input_batches.size()) 412 | print('target_batches', target_batches.size()) 413 | 414 | 415 | # Create models with a small size (in case you need to manually inspect): 416 | 417 | # In[395]: 418 | 419 | # Create models 420 | hidden_size = 8 421 | n_layers = 2 422 | encoder_test = EncoderRNN(input_lang.n_words, hidden_size, n_layers) 423 | decoder_test = LuongAttnDecoderRNN('general', hidden_size, output_lang.n_words, n_layers) 424 | 425 | if USE_CUDA: 426 | encoder_test.cuda() 427 | decoder_test.cuda() 428 | 429 | 430 | # Then running the entire batch of input sequences through the encoder to get per-batch encoder outputs: 431 | 432 | # In[396]: 433 | 434 | # Test encoder 435 | encoder_outputs, encoder_hidden = encoder_test(input_batches, input_lengths, None) 436 | print('encoder_outputs', encoder_outputs.size()) # max_len x B x hidden_size 437 | print('encoder_hidden', encoder_hidden.size()) # n_layers x B x hidden_size 438 | 439 | 440 | # Then starting with a SOS token, run word tokens through the decoder to get each next word token. Instead of doing this with the whole sequence, it is done one at a time, to support using it's own predictions to make the next prediction. This will be one time step at a time, but batched per time step. In order to get this to work for short padded sequences, the batch size is going to get smaller each time. 441 | 442 | # In[397]: 443 | 444 | decoder_attns = torch.zeros(batch_size, MAX_LENGTH, MAX_LENGTH) 445 | decoder_hidden = encoder_hidden 446 | decoder_context = Variable(torch.zeros(1, decoder_test.hidden_size)) 447 | criterion = nn.NLLLoss() 448 | 449 | max_length = max(target_lengths) 450 | all_decoder_outputs = Variable(torch.zeros(max_length, batch_size, decoder_test.output_size)) 451 | 452 | if USE_CUDA: 453 | decoder_context = decoder_context.cuda() 454 | all_decoder_outputs = all_decoder_outputs.cuda() 455 | 456 | loss = 0 457 | 458 | # import masked_cross_entropy 459 | import importlib 460 | importlib.reload(masked_cross_entropy) 461 | 462 | # Run through decoder one time step at a time 463 | for t in range(max_length - 1): 464 | decoder_input = target_batches[t] 465 | target_batch = target_batches[t + 1] 466 | 467 | decoder_output, decoder_context, decoder_hidden, decoder_attn = decoder_test( 468 | decoder_input, decoder_context, decoder_hidden, encoder_outputs 469 | ) 470 | print('decoder output = %s, decoder_hidden = %s, decoder_attn = %s'% ( 471 | decoder_output.size(), decoder_hidden.size(), decoder_attn.size() 472 | )) 473 | all_decoder_outputs[t] = decoder_output 474 | 475 | # print('all decoder outputs', all_decoder_outputs.size()) 476 | # print('target batches', target_batches.size()) 477 | # print('all_decoder_outputs', all_decoder_outputs.transpose(0, 1).contiguous().view(-1, decoder_test.output_size)) 478 | print('target lengths', target_lengths) 479 | loss = masked_cross_entropy.compute_loss( 480 | all_decoder_outputs.transpose(0, 1).contiguous(), 481 | target_batches.transpose(0, 1).contiguous(), 482 | target_lengths 483 | ) 484 | # loss = criterion(all_decoder_outputs, target_batches) 485 | # print('loss', loss.size()) 486 | print('loss', loss.data[0]) 487 | 488 | 489 | # # Training 490 | # 491 | # ## Defining a training iteration 492 | # 493 | # To train we first run the input sentence through the encoder word by word, and keep track of every output and the latest hidden state. Next the decoder is given the last hidden state of the decoder as its first hidden state, and the `` token as its first input. From there we iterate to predict a next token from the decoder. 494 | # 495 | # ### Teacher Forcing vs. Scheduled Sampling 496 | # 497 | # "Teacher Forcing", or maximum likelihood sampling, means using the real target outputs as each next input when training. The alternative is using the decoder's own guess as the next input. Using teacher forcing may cause the network to converge faster, but [when the trained network is exploited, it may exhibit instability](http://minds.jacobs-university.de/sites/default/files/uploads/papers/ESNTutorialRev.pdf). 498 | # 499 | # You can observe outputs of teacher-forced networks that read with coherent grammar but wander far from the correct translation - you could think of it as having learned how to listen to the teacher's instructions, without learning how to venture out on its own. 500 | # 501 | # The solution to the teacher-forcing "problem" is known as [Scheduled Sampling](https://arxiv.org/abs/1506.03099), which simply alternates between using the target values and predicted values when training. We will randomly choose to use teacher forcing with an if statement while training - sometimes we'll feed use real target as the input (ignoring the decoder's output), sometimes we'll use the decoder's output. 502 | 503 | # In[398]: 504 | 505 | [SOS_token] * 5 506 | 507 | 508 | # In[399]: 509 | 510 | def train(input_batches, input_lengths, target_batches, target_lengths, encoder, decoder, encoder_optimizer, decoder_optimizer, criterion, max_length=MAX_LENGTH): 511 | 512 | # Zero gradients of both optimizers 513 | encoder_optimizer.zero_grad() 514 | decoder_optimizer.zero_grad() 515 | loss = 0 # Added onto for each word 516 | 517 | # Run words through encoder 518 | encoder_outputs, encoder_hidden = encoder(input_batches, input_lengths, None) 519 | 520 | # Prepare input and output variables 521 | decoder_input = Variable(torch.LongTensor([[SOS_token] * batch_size])).transpose(0, 1) 522 | # print('decoder_input', decoder_input.size()) 523 | decoder_context = encoder_outputs[-1] 524 | decoder_hidden = encoder_hidden # Use last hidden state from encoder to start decoder 525 | 526 | max_length = max(target_lengths) 527 | all_decoder_outputs = Variable(torch.zeros(max_length, batch_size, decoder.output_size)) 528 | 529 | # Move new Variables to CUDA 530 | if USE_CUDA: 531 | decoder_input = decoder_input.cuda() 532 | decoder_context = decoder_context.cuda() 533 | all_decoder_outputs = all_decoder_outputs.cuda() 534 | 535 | # Choose whether to use teacher forcing 536 | use_teacher_forcing = random.random() < teacher_forcing_ratio 537 | 538 | # TODO: Get targets working 539 | if True: 540 | # Run through decoder one time step at a time 541 | for t in range(max_length): 542 | # target_batch = target_batches[t] 543 | 544 | # Trim down batches of other inputs 545 | # decoder_hidden = decoder_hidden[:, :len(target_batch)] 546 | # encoder_outputs = encoder_outputs[:, :len(target_batch)] 547 | 548 | decoder_output, decoder_context, decoder_hidden, decoder_attn = decoder( 549 | decoder_input, decoder_context, decoder_hidden, encoder_outputs 550 | ) 551 | # print(decoder_output.size(), decoder_hidden.size(), decoder_attn.size()) 552 | 553 | # loss += criterion(decoder_output, target_batch) 554 | all_decoder_outputs[t] = decoder_output 555 | 556 | decoder_input = target_batches[t] 557 | # TODO decoder_input = target_variable[di] # Next target is next input 558 | 559 | # Teacher forcing: Use the ground-truth target as the next input 560 | elif use_teacher_forcing: 561 | for di in range(target_length): 562 | decoder_output, decoder_context, decoder_hidden, decoder_attention = decoder(decoder_input, decoder_context, decoder_hidden, encoder_outputs) 563 | loss += criterion(decoder_output[0], target_variable[di]) 564 | decoder_input = target_variable[di] # Next target is next input 565 | 566 | # Without teacher forcing: use network's own prediction as the next input 567 | else: 568 | for di in range(target_length): 569 | decoder_output, decoder_context, decoder_hidden, decoder_attention = decoder(decoder_input, decoder_context, decoder_hidden, encoder_outputs) 570 | loss += criterion(decoder_output[0], target_variable[di]) 571 | 572 | # Get most likely word index (highest value) from output 573 | topv, topi = decoder_output.data.topk(1) 574 | ni = topi[0][0] 575 | 576 | decoder_input = Variable(torch.LongTensor([[ni]])) # Chosen word is next input 577 | if USE_CUDA: decoder_input = decoder_input.cuda() 578 | 579 | # Stop at end of sentence (not necessary when using known targets) 580 | if ni == EOS_token: break 581 | 582 | # Loss calculation and backpropagation 583 | # print('all_decoder_outputs', all_decoder_outputs.size()) 584 | # print('target_batches', target_batches.size()) 585 | loss = masked_cross_entropy.compute_loss( 586 | all_decoder_outputs.transpose(0, 1).contiguous(), # seq x batch -> batch x seq 587 | target_batches.transpose(0, 1).contiguous(), # seq x batch -> batch x seq 588 | target_lengths 589 | ) 590 | 591 | loss.backward() 592 | 593 | # Clip gradient norm 594 | # ec = torch.nn.utils.clip_grad_norm(encoder.parameters(), clip) 595 | # dc = torch.nn.utils.clip_grad_norm(decoder.parameters(), clip) 596 | 597 | # Update parameters with optimizers 598 | encoder_optimizer.step() 599 | decoder_optimizer.step() 600 | 601 | return loss.data[0], ec, dc 602 | 603 | # ## Running training 604 | 605 | # Plus helper functions to print time elapsed and estimated time remaining, given the current time and progress. 606 | 607 | # In[404]: 608 | 609 | def as_minutes(s): 610 | m = math.floor(s / 60) 611 | s -= m * 60 612 | return '%dm %ds' % (m, s) 613 | 614 | def time_since(since, percent): 615 | now = time.time() 616 | s = now - since 617 | es = s / (percent) 618 | rs = es - s 619 | return '%s (- %s)' % (as_minutes(s), as_minutes(rs)) 620 | 621 | def evaluate(input_seq, max_length=MAX_LENGTH): 622 | input_lengths = [len(input_seq)] 623 | input_seqs = [indexes_from_sentence(input_lang, input_seq)] 624 | input_batches = Variable(torch.LongTensor(input_seqs)).transpose(0, 1) 625 | if USE_CUDA: 626 | input_batches = input_batches.cuda() 627 | 628 | # Run through encoder 629 | encoder_outputs, encoder_hidden = encoder(input_batches, input_lengths, None) 630 | 631 | # Create starting vectors for decoder 632 | decoder_input = Variable(torch.LongTensor([[SOS_token]])) # SOS 633 | decoder_context = Variable(torch.zeros(1, decoder.hidden_size)) 634 | decoder_hidden = encoder_hidden 635 | 636 | if USE_CUDA: 637 | decoder_input = decoder_input.cuda() 638 | decoder_context = decoder_context.cuda() 639 | 640 | # Store output words and attention states 641 | decoded_words = [] 642 | decoder_attentions = torch.zeros(max_length + 1, max_length + 1) 643 | 644 | # Run through decoder 645 | for di in range(max_length): 646 | decoder_output, decoder_context, decoder_hidden, decoder_attention = decoder( 647 | decoder_input, decoder_context, decoder_hidden, encoder_outputs 648 | ) 649 | decoder_attentions[di,:decoder_attention.size(2)] += decoder_attention.squeeze(0).squeeze(0).cpu().data 650 | 651 | # Choose top word from output 652 | topv, topi = decoder_output.data.topk(1) 653 | ni = topi[0][0] 654 | if ni == EOS_token: 655 | decoded_words.append('') 656 | break 657 | else: 658 | decoded_words.append(output_lang.index2word[ni]) 659 | 660 | # Next input is chosen word 661 | # THIS MIGHT BE THE LAST PART OF BATCHING (or is it already going?) 662 | decoder_input = Variable(torch.LongTensor([[ni]])) 663 | if USE_CUDA: decoder_input = decoder_input.cuda() 664 | 665 | return decoded_words, decoder_attentions[:di+1, :len(encoder_outputs)] 666 | 667 | def evaluate_randomly(): 668 | pair = random.choice(pairs) 669 | 670 | output_words, attentions = evaluate(pair[0]) 671 | output_sentence = ' '.join(output_words) 672 | show_attention(pair[0], output_words, attentions) 673 | 674 | print('>', pair[0]) 675 | print('=', pair[1]) 676 | print('<', output_sentence) 677 | print('') 678 | 679 | def show_plot_visdom(): 680 | buf = io.BytesIO() 681 | plt.savefig(buf) 682 | buf.seek(0) 683 | attn_win = 'attention (%s)' % hostname 684 | vis.image(torchvision.transforms.ToTensor()(Image.open(buf)), win=attn_win, opts={'title': attn_win}) 685 | 686 | def show_attention(input_sentence, output_words, attentions): 687 | # Set up figure with colorbar 688 | fig = plt.figure() 689 | ax = fig.add_subplot(111) 690 | cax = ax.matshow(attentions.numpy(), cmap='bone') 691 | fig.colorbar(cax) 692 | 693 | # Set up axes 694 | ax.set_xticklabels([''] + input_sentence.split(' ') + [''], rotation=90) 695 | ax.set_yticklabels([''] + output_words) 696 | 697 | # Show label at every tick 698 | ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) 699 | ax.yaxis.set_major_locator(ticker.MultipleLocator(1)) 700 | 701 | show_plot_visdom() 702 | plt.show() 703 | plt.close() 704 | 705 | def evaluate_and_show_attention(input_sentence): 706 | output_words, attentions = evaluate(input_sentence) 707 | print('input =', input_sentence) 708 | print('output =', ' '.join(output_words)) 709 | show_attention(input_sentence, output_words, attentions) 710 | win = 'evaluted (%s)' % hostname 711 | text = '

> %s

= %s

< %s

' % (input_sentence, target_sentence, output_sentence) 712 | vis.text(text, win=win, opts={'title': win}) 713 | 714 | 715 | # Begin! 716 | ecs = [] 717 | dcs = [] 718 | eca = 0 719 | dca = 0 720 | 721 | while epoch < n_epochs: 722 | epoch += 1 723 | 724 | # Get training data for this cycle 725 | input_batches, input_lengths, target_batches, target_lengths = random_batch(batch_size) 726 | 727 | # Run the train function 728 | loss, ec, dc = train( 729 | input_batches, input_lengths, target_batches, target_lengths, 730 | encoder, decoder, 731 | encoder_optimizer, decoder_optimizer, criterion 732 | ) 733 | 734 | # Keep track of loss 735 | print_loss_total += loss 736 | plot_loss_total += loss 737 | eca += ec 738 | dca += dc 739 | 740 | if epoch == 1: 741 | evaluate_randomly() 742 | continue 743 | 744 | if epoch % print_every == 0: 745 | print_loss_avg = print_loss_total / print_every 746 | print_loss_total = 0 747 | print_summary = '%s (%d %d%%) %.4f' % (time_since(start, epoch / n_epochs), epoch, epoch / n_epochs * 100, print_loss_avg) 748 | print(print_summary) 749 | evaluate_randomly() 750 | 751 | if epoch % plot_every == 0: 752 | plot_loss_avg = plot_loss_total / plot_every 753 | plot_losses.append(plot_loss_avg) 754 | plot_loss_total = 0 755 | 756 | # TODO: Running average helper 757 | ecs.append(eca / plot_every) 758 | dcs.append(dca / plot_every) 759 | ecs_win = 'encoder grad (%s)' % hostname 760 | dcs_win = 'decoder grad (%s)' % hostname 761 | vis.line(np.array(ecs), win=ecs_win, opts={'title': ecs_win}) 762 | vis.line(np.array(dcs), win=dcs_win, opts={'title': dcs_win}) 763 | eca = 0 764 | dca = 0 765 | 766 | --------------------------------------------------------------------------------