Skip to content

Instantly share code, notes, and snippets.

function gssh() {
gcloud compute ssh $@
}
gssh $INSTANCE_NAME
function ginstance_stop() {
gcloud compute instances stop - quiet $@
}
ginstance_stop $INSTANCE_NAME
export IMAGE_NAME="my-awesome-image"
export IMAGE_FAMILY="family1"
gcloud compute images create $IMAGE_NAME \
--source-disk $INSTANCE_NAME \
--source-disk-zone $ZONE \
--family $IMAGE_FAMILY
gssh $INSTANCE_NAME -- -L 8080:localhost:8080
export IMAGE_FAMILY="tf-latest-cu92"
export ZONE="us-west1-b"
export INSTANCE_NAME="chat-bot-trainer"
gcloud compute instances create $INSTANCE_NAME \
--zone=$ZONE \
--image-family=$IMAGE_FAMILY \
--image-project=deeplearning-platform-release \
--maintenance-policy=TERMINATE \
--accelerator='type=nvidia-tesla-v100,count=1' \
--metadata='install-nvidia-driver=True'
wget https://gist.github.com/b0noI/9c6ff272c813dab5f4a4869597771007/raw/5185a23cd061cef12bb9524527f1cdc71faf3a9f/nltk_prep.py
python nltk_prep.py
# Dialog convertor
git clone https://github.com/b0noI/dialog_converter.git
cd dialog_converter
git checkout b9cc7b7d82a959c80e5048b18e956841233c7688
python3 ./converter.py
cd ..
# Subwork NMT
git clone https://github.com/b0noI/subword-nmt.git
cd subword-nmt
wget https://gist.githubusercontent.com/b0noI/174959e2056702e64a5ca39853a9816d/raw/d90f6c97433a2e53778f64d5722ab99577c42fda/train_chatbot.sh
bash train_chatbot.sh
cd ~
cd nmt
touch ~/content/output
chat () {
echo $1 > ~/content/input
python3 $HOME/pre_processing.py ~/content/input >~/content/input.pre
$HOME/subword-nmt/apply_bpe.py -c $HOME/code.bpe --vocabulary $HOME/vocab.train.bpe.a --vocabulary-threshold 5 < ~/content/input.pre > `/content/input.pre.bpe
cd $HOME/nmt
python -m nmt.nmt --out_dir=~/content/nmt_model --inference_input_file=~/content/input.pre.bpe --inference_output_file=~/content/output > /dev/null 2>&1
gcloud compute images describe-from-family tf-latest-cu92 --project=deeplearning-platform-release --format "value(name)"