Using character sequences in first names to predict gender.
In this approach, I feed characters in a name one by one through a character level long short-term memory (LSTM) network built in PyTorch in the hopes of learning the latent space of all character sequences that denote gender without having to define them a priori.
(optional for GPU training)
- PyTorch = 1.7
- NVIDIA GPU + CUDA
-
Clone repo
git clone https://github.com/wstmac/name2gender.git
-
Install Dependencies
cd name2gender pip install -r requirements.txt
* If you cannot successfully install pytorch, you can install it with conda command, which you can find https://pytorch.org/get-started/previous-versions/ e.g.
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
-
go the the data directory by typing:
cd data
-
clean the first name and split the whole data into train, val and testing. Defualt split ratio are 0.8, 0.1, 0.1 for train, val and test respectively.
python clean_data.py
All logging files in the training process, e.g., log message, checkpoints, and snapshots, will be saved to ./results
and ./logging
directory.
-
Modify config files.
configuration.py
-
Run training code (I have tunned some hyperparameters and set them as the default value. You can just run below command to train the network).
python train.py
I implement grid search for the hyperparameter tuning. You can run multiple hyperparameter combination with the bash script.
bash gird_search.sh