Looking for Colab notebooks to learn from? Check out Seedbank, a place to discover interactive machine learning examples.
In [0]:
Hi. Can it be saved?
Colaboratory allows you to execute TensorFlow code in your browser with a single click. The example below adds two matrices.
$\begin{bmatrix}
In [0]:
import tensorflow as tf
input1 = tf.ones((2, 3))
input2 = tf.reshape(tf.range(1, 7, dtype=tf.float32), (2, 3))
output = input1 + input2
with tf.Session():
result = output.eval()
result
Out[0]:
For a full discussion of interactions between Colab and GitHub, see . As a brief summary:
To save a copy of your Colab notebook to Github, select File → Save a copy to GitHub…
To load a specific notebook from github, append the github path to http://colab.research.google.com/github/. For example to load this notebook in Colab: https://github.com/tensorflow/docs/blob/master/site/en/tutorials/_index.ipynb use the following Colab URL:
To open a github notebook in one click, we recommend installing the Open in Colab Chrome Extension.
Colaboratory includes widely used libraries like matplotlib, simplifying visualization.
In [0]:
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(20)
y = [x_i + np.random.randn(1) for x_i in x]
a, b = np.polyfit(x, y, 1)
_ = plt.plot(x, y, 'o', np.arange(20), a*np.arange(20)+b, '-')
Want to use a new library? pip install
it at the top of the notebook. Then that library can be used anywhere else in the notebook. For recipes to import commonly used libraries, refer to the importing libraries example notebook.
In [0]:
!pip install -q matplotlib-venn
from matplotlib_venn import venn2
_ = venn2(subsets = (3, 2, 1))
Forms can be used to parameterize code. See the forms example notebook for more details.
In [0]:
#@title Examples
text = 'value' #@param
date_input = '2018-03-22' #@param {type:"date"}
number_slider = 0 #@param {type:"slider", min:-1, max:1, step:0.1}
dropdown = '1st option' #@param ["1st option", "2nd option", "3rd option"]
Colab supports connecting to a Jupyter runtime on your local machine. For more information, see our documentation.
In [0]: