#!/usr/bin/env python # coding: utf-8 # JupyterLab # ========== # # Sergey Zagoruyko @ WILLOW # Next iteration of Jupyter, ready to use! # # My experience for keeping track of experiments: # * Jupyter since 2015 (3 years+) # * JupyterLab since 2018 (about 1 year) # # The most powerful feature: # * **Extensions** # ## Install # # a bit messy but installs nodejs: # # ```bash # conda install -c conda-forge jupyterlab # ``` # # otherwise: # # ```bash # pip install jupyterlab # ``` # ## Vim mode # # Text editing (e.g. python code or yaml files) supports by default Sublime, Emacs and Vim. # # To edit Jupyter cells there is Vim extension: # # Install with: # # ``` # jupyter labextension install jupyterlab_vim # ``` # # # ## Kernels # # * IPyKernel # * IJulia # * IHaskell # * Matlab Kernel # * IOctave # # and others # ## UI improvements # # * Built-in terminals # * Moving cells # * Panes # ## Visual Studio Code integration # # Microsoft Python extension allows importing and editing jupyter files: # # # ## Visualizations # # ### Videos # In[10]: from IPython.display import HTML youtube_id = 'ctOM-Gza04Y' HTML(f'') # ### Pandas # In[11]: import pandas as pd pd.read_json('/sequoia/data1/szagoruy/tmp/47179/exp_args.json') # ## Matplotlib # In[12]: get_ipython().run_line_magic('pylab', 'inline') get_ipython().run_line_magic('config', "InlineBackend.figure_format = 'retina'") import seaborn as sns import torch sns.set() # In[13]: a = torch.rand(64, 64, 3) plt.imshow(a) # In[14]: pd.DataFrame({'x': torch.randn(128).cumsum(0), 'y': torch.randn(128).cumsum(0), }).plot.hist(figsize=(16,8), alpha=0.8); # ### Graphs # In[15]: import torch from torch import nn from torchviz import make_dot # In[16]: lstm_cell = nn.LSTMCell(128, 128) x = torch.randn(1, 128) make_dot(lstm_cell(x), params=dict(list(lstm_cell.named_parameters()))) # ### LaTex rendering # # Besides writing equations in jupyter cells like that: $$D_{KL} = \sum_i p(i) \log \frac{p(i)}{q(i)},$$ # it is possible to write latex files that get compiled and rendered in Jupyter lab. # ## ipynb sharing # * https://gist.github.com # * https://nbviewer.jupyter.org # ## Debugging # # `%pdb on` / `%pdb off` magick turns on debugging on errors # ## Downsides # # **Not a complete IDE!**: # * Git integration is pain (although there are attemps to improve it) # * No linter # * Execution order is mess # * Code completion is not as good as VSCode or Atom (no completion outside of kernels) # ## My workflow # # With JupyterLab: # * Keep track of experiments (converge curves, notes) # * Visualizations (debugging, share notebooks with other people) # * Start new jobs on cluster # # For writing code I use IDE (mostly vim, sometimes VSCode). # In[ ]: