- SeedBank by Google: Collection of Interactive Machine Learning Examples.
👉 Check this section too.
Check the command shortcuts in Tools > Keyboard shortcuts (
Ctrl + M H), below are the most popular ones (If you use MacOS, replace Ctrl with cmd):We can use system commands in Colab with
!<command>. For example, !git clone ...1!pip install -q matplotlib-venn
2# or
3!apt-get -qq install -y libfluidsynth11# To determine which version you're using:
2!pip show tensorflow1# For the current version:
2!pip install --upgrade tensorflow1# For a specific version:
2!pip install tensorflow==1.21# For the latest nightly build:
2!pip install tf-nightlyCheck out Git
1# Initialize the git repository (optional)
2!git init1# Set the global username and email
2!git config --global user.email "[email protected]"
3!git config --global user.name "Your Name"1# Add all the files
2!git add -A
3# or
4!git add .1# Commit
2!git commit -m "Comment for that commit"1# Pass your Github credentials
2!git remote rm origin # in the case you meet "fatal: remote origin already exists"
3!git remote add origin <https://<github-username>:<github-password>@github.com/><github-username>/<repository-name>.git1# Push to origin
2!git push -u origin masterIf you don't want to use your username andd password, you can use "Personal access tokens" on Github. Create one here and then use,
1!git git remote add origin <https://<username>:<access-token>@github.com/><username>/<repo>.gitF1 then Console and type,1function ClickConnect(){
2 console.log("Working");
3 document.querySelector("colab-connect-button").shadowRoot.getElementById("connect").click()
4}
5setInterval(ClickConnect,60000)By default, the working directory is
/content/. One can use below command to change to another place,1%cd /content/data-science-learningFrom that point, we are working on
/content/data-science-learning.Each user has a "machine" in
/content/.Create a new cell and paste,
1from google.colab import files
2
3uploaded = files.upload()
4
5for fn in uploaded.keys():
6 print('User uploaded file "{name}" with length {length} bytes'.format(
7 name=fn, length=len(uploaded[fn])))Run 2 times this cell, at the 2nd time, you can choose your file.
Run a cell containing following codes,
1from google.colab import drive
2drive.mount('/content/drive')and then follow the guide on the screen. In order to access to the drive,
1with open('/content/drive/My Drive/foo.txt', 'w') as f:
2 f.write('Hello Google Drive!')1!git clone <https://github.com/dinhanhthi/data-science-learning.git>The cloned folder are stored in
/content/. If you wanna pull requests, use,1%cd /content/data-science-learning
2!git pullTo enable GPU backend for your notebook, go to Edit → Notebook Settings and set Hardware accelerator to GPU. (ref)
1# <https://pypi.python.org/pypi/libarchive>
2!apt-get -qq install -y libarchive-dev && pip install -q -U libarchive
3import libarchive1# <https://pypi.python.org/pypi/pydot>
2!apt-get -qq install -y graphviz && pip install -q pydot
3import pydot1!apt-get -qq install python-cartopy python3-cartopy
2import cartopyJupyter Notebook has an option to 'Download as' HTML (or other) format. Google Colaboratory does not.
- Save your Colab notebook.
- In your terminal:
1jupyter nbconvert --to <output format> <filename.ipynb>
2# jupyter nbconvert --to html mynotebook.ipynb- Interrupt a long running python process: Runtime > Interrupt execution (
Alt + M + I).
- Support Jupyter magic commands, check full list here.