「Colaboratory」の版間の差分
提供: fukudat.net
ナビゲーションに移動検索に移動
(ページの作成:「Colaboratory は[https://www.google.com Google]のリサーチプロジェクトで、機械学習の教育と研...」) |
|||
| (同じ利用者による、間の1版が非表示) | |||
| 38行目: | 38行目: | ||
</pre> | </pre> | ||
| − | ただし、<tt>mount_point</tt>はGoogle Driveをマウントするマウントポイント (directory) | + | ただし、<tt>mount_point</tt>はGoogle Driveをマウントするマウントポイント (directory)。存在しなければ作成する。 |
| − | + | directoryが空でないとエラーが出る。 | |
== ファイルのアップロード == | == ファイルのアップロード == | ||
| 48行目: | 48行目: | ||
uploaded = files.upload() | uploaded = files.upload() | ||
</pre> | </pre> | ||
| − | + | upload用のダイアログが現れるので、ファイルを指定する。 | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
2018年6月14日 (木) 00:18時点における最新版
Colaboratory はGoogleのリサーチプロジェクトで、機械学習の教育と研究を普及させるために作られた。 Jupyter notebookの環境で、事前の設定は必要なく、完全にクラウド上で動作する。
Welcomeページに主な使い方が書かれている。
起動
単に Colaboratoryのmain pageにアクセスし、Google accountでログインする。
Google Driveのマウント
Colaboratoryで以下を実行。
# installing packages
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools >/dev/null 2>&1
!add-apt-repository -y ppa:alessandro-strada/ppa > /dev/null 2>&1
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse >/dev/null 2>&1
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
# authenticating
import getpass
prompt = !google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
if prompt:
print(prompt, end='')
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} >/dev/null 2>&1
# mounting google drive
mount_point = "/content/drive" # @param { type: "string" }
!mkdir -p {mount_point}
!google-drive-ocamlfuse {mount_point}
!df -k /content/drive
ただし、mount_pointはGoogle Driveをマウントするマウントポイント (directory)。存在しなければ作成する。 directoryが空でないとエラーが出る。
ファイルのアップロード
Colaboratoryで以下を実行する。
# showing a upload dialog from google.colab import files uploaded = files.upload()
upload用のダイアログが現れるので、ファイルを指定する。