Colab常用命令备忘

(1)
from google.colab import drive
drive.mount('/content/drive/')

(2)
!ls "/content/drive/My Drive/"

(3)
!python3 "/content/drive/My Drive/Colab/app/mnist_cnn.py"

(4)
!wget https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/Titanic.csv -P "/content/drive/My Drive/app"

(5)
import os
os.chdir("/drive/My Drive/Colab/app")
!ls
!git clone https://github.com/wxs/keras-mnist-tutorial.git
!ls

(6)
In order to restart (or reset) your virtual machine, simply run:
!kill -9 -1
需要重新挂载

(7)tensorboard
# You can change the directory name
LOG_DIR = 'tb_logs'

!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip ngrok-stable-linux-amd64.zip

import os
if not os.path.exists(LOG_DIR):
  os.makedirs(LOG_DIR)
  
get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'
    .format(LOG_DIR))

get_ipython().system_raw('./ngrok http 6006 &')

!curl -s http://localhost:4040/api/tunnels | python3 -c \
    "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"

 

你可能感兴趣的:(项目记录)