RNN-LSTM example on Language Modeling

Schematic of colab.com service

Fig.1 overall process of colab.com service

Fig.1 shows the overall process of colab.com service.


Example

The document below demonstrates how to upload files in PC, project in GitHub and execute Python code in Colab.

第一步. 下載 data [1]。

網址 : http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz

下載後是一個壓縮檔,檔名是 "simple-examples.tgz"。解壓縮後進入 "simple-examples\data" 目錄下,裡面的 "ptb.train.txt", "ptb.valid.txt", "ptb.text.txt" 三個檔案,第三步需要。

第二步. 登入 Colab,將 GitHub 上的 project 複製 (git clone) 到 Colab 上

Clone project from GitHub to Colab using !git clone https://github.com/tensorflow/models.git command.Fig.2 clone project from GitHub to Colab

第三步. 移動至 models/tutorials/rnn/ptb 目錄下

Move to the project folder using cd command with the folder path

Fig.3 move to the project folder

check which files and folder in /content/models/tutorials/rnn/ptb folder using !ls commandFig.4 check which files and folder in this path

第四步. 上傳 "ptb.train.txt", "ptb.valid.txt", "ptb.text.txt" 三個檔案到 Colab 上

Upload files from PC to Colab using the library files in google.colab

from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
    print('User uploaded file"{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))

Fig.5 upload files from PC to Colab

Fig.5 shows upload files from PC to Colab using the library files in google.colab, then upload files by clicking "選擇檔案" button

第五步. 執行 python 程式 ptb_word_lm.py

Execute ".py" file using !pythoncommand, with parameters --data_path and --model then Colab output to browserFig.6 execute the .py file

End of the execution

Fig.7 end of the execution


Reference

[0] Recurrent Neural Network

https://www.tensorflow.org/tutorials/recurrent

[1] dataset

http://www.fit.vutbr.cz/~imikolov/rnnlm/simple-examples.tgz

results matching ""

    No results matching ""