iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐥

Revisiting Google Colab in 2025: Discovering Overlooked Features

に公開

Introduction

This document is a memo of my "re-investigation" into the features of Google Colab as of 2025/09/25, which I used to pay for in the past. For those using Google Colab for the first time, please refer to other introductory documents. Also, since I am currently not subscribed, paid features have not been verified.

Screen Effects

There are settings to apply screen effects. They provide a glimmer of hope when you're fed up with everything.

In the menu at the top of the screen, select Tools → Settings to display the settings dialog.

Select "Miscellaneous"

Power Level

You can make sparks fly while coding.
https://x.com/GoogleColab/status/1112708634905964545

Corgi Mode/Cat Mode/Crab Mode

Corgis, cats, and crabs will move across the top of the screen.

Changing the Runtime Type

Runtime Versions

It is now possible to select past runtimes.

Previously, there were cases where code stopped working due to version updates, but with the ability to select past runtimes, reproducing past code has become easier.
Past runtime versions are available for one year after their release.

Frequently Asked Questions - Past Runtime Versions

Runtime Types

In addition to Python 3, R and Julia are now available.

Example of Python

Code

import numpy as np

# Sample matrix/vector (Same as Python)
A = np.array([[3, 1, 2],
              [0, 1, 4],
              [2, 3, 1]], dtype=float)

B = np.array([[1, 2, 3],
              [4, 5, 6],
              [7, 8, 9]], dtype=float)

b = np.array([1, 2, 3], dtype=float)

# 1) Matrix multiplication
C = A @ B

# 2) Transpose
AT = A.T

# 3) Determinant
detA = np.linalg.det(A)

# 4) Inverse matrix
invA = np.linalg.inv(A)

# 5) Solution to the system of linear equations A x = b
x = np.linalg.solve(A, b)

# 6) Eigenvalues (if you want eigenvectors, it's the 2nd return value of eig)
w, v = np.linalg.eig(A)   # w: eigenvalues, v: column vectors are eigenvectors

# 7) Element-wise product (Hadamard product)
hadamard = A * B

print("C=\n", C)
print("A^T=\n", AT)
print("det(A)=", detA)
print("inv(A)=\n", invA)
print("x=\n", x)
print("eigvals(A)=\n", w)
print("A .* B=\n", hadamard)

Output

C=
 [[21. 27. 33.]
 [32. 37. 42.]
 [21. 27. 33.]]
A^T=
 [[3. 0. 2.]
 [1. 1. 3.]
 [2. 4. 1.]]
det(A)= -29.000000000000018
inv(A)=
 [[ 0.37931034 -0.17241379 -0.06896552]
 [-0.27586207  0.03448276  0.4137931 ]
 [ 0.06896552  0.24137931 -0.10344828]]
x=
 [-0.17241379  1.03448276  0.24137931]
eigvals(A)=
 [-2.62721301  1.94136684  5.68584617]
A .* B=
 [[ 3.  2.  6.]
 [ 0.  5. 24.]
 [14. 24.  9.]]
Example of R

Code

# Sample matrix/vector (Same as Python)
A <- matrix(c(3,1,2,
              0,1,4,
              2,3,1), nrow=3, byrow=TRUE)

B <- matrix(c(1,2,3,
              4,5,6,
              7,8,9), nrow=3, byrow=TRUE)

b <- c(1,2,3)

# 1) Matrix multiplication
C <- A %*% B

# 2) Transpose
AT <- t(A)

# 3) Determinant
detA <- det(A)

# 4) Inverse matrix
invA <- solve(A)

# 5) Solution to the system of linear equations A x = b
x <- solve(A, b)

# 6) Eigenvalues (Eigenvectors are in $vectors)
eig <- eigen(A)   # eig$values, eig$vectors

# 7) Element-wise product (Hadamard product)
hadamard <- A * B

print(C)
print(AT)
print(detA)
print(invA)
print(x)
print(eig$values)
print(hadamard)

Output
The order of eigenvalues may differ from Python.

     [,1] [,2] [,3]
[1,]   21   27   33
[2,]   32   37   42
[3,]   21   27   33
     [,1] [,2] [,3]
[1,]    3    0    2
[2,]    1    1    3
[3,]    2    4    1
[1] -29
            [,1]        [,2]        [,3]
[1,]  0.37931034 -0.17241379 -0.06896552
[2,] -0.27586207  0.03448276  0.41379310
[3,]  0.06896552  0.24137931 -0.10344828
[1] -0.1724138  1.0344828  0.2413793
[1]  5.685846 -2.627213  1.941367
     [,1] [,2] [,3]
[1,]    3    2    6
[2,]    0    5   24
[3,]   14   24    9
Example of Julia

Example Code

using LinearAlgebra   # det, inv, eigen, etc.

# Sample matrix/vector (Same as Python)
A = [3.0 1.0 2.0;
     0.0 1.0 4.0;
     2.0 3.0 1.0]

B = [1.0 2.0 3.0;
     4.0 5.0 6.0;
     7.0 8.0 9.0]

b = [1.0, 2.0, 3.0]

# 1) Matrix multiplication
C = A * B

# 2) Transpose (non-conjugate transpose)
AT = transpose(A)

# 3) Determinant
detA = det(A)

# 4) Inverse matrix
invA = inv(A)

# 5) Solution to the system of linear equations A x = b (\ is recommended in Julia)
x = A \ b

# 6) Eigenvalues (Eigenvectors are in .vectors)
eig = eigen(A)      # eig.values, eig.vectors

# 7) Element-wise product (Hadamard product)
hadamard = A .* B

println("C=\n", C)
println("A^T=\n", AT)
println("det(A)=", detA)
println("inv(A)=\n", invA)
println("x=\n", x)
println("eigvals(A)=\n", eig.values)
println("A .* B=\n", hadamard)

Output

C=
[21.0 27.0 33.0; 32.0 37.0 42.0; 21.0 27.0 33.0]
A^T=
[3.0 0.0 2.0; 1.0 1.0 3.0; 2.0 4.0 1.0]
det(A)=-29.000000000000004
inv(A)=
[0.3793103448275862 -0.17241379310344823 -0.06896551724137932; -0.27586206896551724 0.03448275862068964 0.41379310344827586; 0.0689655172413793 0.24137931034482757 -0.10344827586206895]
x=
[-0.1724137931034482, 1.0344827586206895, 0.24137931034482757]
eigvals(A)=
[-2.6272130052966602, 1.9413668397423212, 5.685846165554339]
A .* B=
[3.0 2.0 6.0; 0.0 5.0 24.0; 14.0 24.0 9.0]

Type Checking

There is an option to perform type checking.

By default, type checking is not performed, as shown below.

Open the settings dialog from the menu: Tools → Settings.
In the settings dialog, go to Editor → Code diagnostics and select "Syntax and type checking".

This enables type checking.

Secret Keys

You can set secret keys by selecting the icon in the left navigation menu.

Example of retrieving a secret key in Python

from google.colab import userdata
userdata.get('test_key')

It is likely unavailable when using R or Julia runtimes.
https://github.com/googlecolab/colabtools/issues/5151#issuecomment-2708334266

Methods I tried that didn't work

While you can run Python from R and other languages, the Python instance running is not the Colab Python, so it seems impossible to retrieve secrets.

library(reticulate)

out <- py_capture_output({
  py_run_string("
from google.colab import userdata
try:
    print(userdata.get('test_key'))
except Exception as e:
    print(e)
")
})
cat(out)
'NoneType' object has no attribute 'kernel'

Also, no library corresponding to google.colab was found.

GitHub Integration

Integration with GitHub, including private repositories, is possible through the following steps:

  1. Select Tools → Settings to open the settings dialog.
  2. Select the GitHub tab in the settings dialog.

The steps to open a notebook are as follows:

File menu → Open notebook

Select the GitHub tab and choose the repository and branch.

Saving the file allows you to commit to GitHub.

Slideshow

You can run a slideshow for presentations.

View → Start slideshow


Opening in Playground Mode

The notebook opens in read-only mode, and edits are made to a copy. No changes are made to the original repository or Drive.


Notebook Diff

In the menu at the top of the screen: Tools → Notebook diff

Summary

By the way, most of the features I found this time have existed for more than a year.

It's surprising how much you don't notice when you're just using it out of habit.

Discussion