mirror of
https://github.com/wassname/keras-language-modeling.git
synced 2026-09-10 12:15:18 +08:00
added install script for gcp
This commit is contained in:
@@ -17,3 +17,7 @@ treq_eval*
|
||||
*.dict
|
||||
*.model
|
||||
|
||||
# virtual environments
|
||||
venv/
|
||||
ENV/
|
||||
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script will get you up and running on a Google Compute Engine instance
|
||||
# Ubuntu 16.04 (as many CPUs as you like)
|
||||
|
||||
# exit on failure
|
||||
set -e
|
||||
|
||||
# install pip (not installed by default on GCE)
|
||||
sudo apt install python-pip
|
||||
|
||||
# install virtualenv
|
||||
sudo pip install virtualenv
|
||||
|
||||
# create and activate virtual environment
|
||||
virtualenv venv
|
||||
source venv/bin/activate
|
||||
|
||||
# install h5py
|
||||
pip install h5py
|
||||
|
||||
# install tensorflow
|
||||
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl
|
||||
pip install --upgrade $TF_BINARY_URL
|
||||
|
||||
# install keras from source in the home directory
|
||||
git clone https://github.com/fchollet/keras ~/keras/
|
||||
python ~/keras/setup.py install --home ~/keras/
|
||||
echo '{"epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"}' > ~/.keras/keras.json
|
||||
|
||||
# alert user that we're done
|
||||
echo ">==< Successfully installed dependencies >==<"
|
||||
|
||||
@@ -233,7 +233,7 @@ if __name__ == '__main__':
|
||||
'n_words': 22353,
|
||||
'question_len': 150,
|
||||
'answer_len': 150,
|
||||
'margin': 0.2,
|
||||
'margin': 0.05,
|
||||
'initial_embed_weights': 'word2vec_100_dim.embeddings',
|
||||
|
||||
'training': {
|
||||
@@ -243,15 +243,15 @@ if __name__ == '__main__':
|
||||
},
|
||||
|
||||
'similarity': {
|
||||
'mode': 'gesd',
|
||||
'mode': 'cosine',
|
||||
'gamma': 1,
|
||||
'c': 1,
|
||||
'd': 2,
|
||||
}
|
||||
}
|
||||
|
||||
from keras_models import AttentionModel
|
||||
evaluator = Evaluator(conf, model=AttentionModel, optimizer='rmsprop')
|
||||
from keras_models import EmbeddingModel
|
||||
evaluator = Evaluator(conf, model=EmbeddingModel, optimizer='sgd')
|
||||
|
||||
# train the model
|
||||
best_loss = evaluator.train()
|
||||
|
||||
Reference in New Issue
Block a user