Jupyter Notebook 入门级shortcuts 和 tips

Jupyter notebook is a sequential collection of cells. Cell can be in either Edit (green colored) & Command (blue colored) mode, and cell has Raw(R), Markdown(M), and Code(Y) types. 

Cell types can be selected when the cell is in Command mode. To escape from Edit mode to Command mode, hit the ESC key. Once in Command mode, can select the cell type with R, M, Y key.

  1. How to use Jupyter Notebook Remotely: Run your codes on a remote server, while displaying the Jupyter notebook on your local machine
    (1) On the server: cd into the project directory
    $ jupyter notebook --no-browser --port=8889
    (2) On your local machine:
    $ ssh -N -f -L localhost:8888:localhost:8889 username@your_remote_host_name
    (3) On your local machine, open a brower and go to http://localhost:8888
    (4) First time connection between the local and remote machines may requries a token verification:
    The brower will display a promot-up window asking for token, and the token can be found in your remote machine terminal after executing step (1).
    This token verification is only needed for the first time connection. Later connections just go over steps (1) - (3).

  2. Run cell:
    (1) If want to run all cells from the top to bottom altogether, go to the Toolbar-->Cell-->Run All;
    (2) If want to run a single cell:
    a. Shift + Enter: run the cell and initialize a new cell below; b. Ctrl + ENter: run the cell without initializing a new cell below.

  3. Insert a new cell:
    Select the cell above and escape to command mode with ESC, then hit B.

  4. Split a cell:
    Toolbar-->Edit-->Split Cell

  5. Clean up the running outputs of cells:
    (1) Cleaning all cells to prepare for a whole new run (if connect remotely, doing this will refresh the GPUs on the remote server):
    Toolbar--> Restart & Clear Output (2) Cleaning just one cell:
    In command mode (use ESC to get in command mode), hit R to change to Raw type, then switch back to code type with Y.

  6. Display line number in cells:
    Toolbar-->View-->Toggle Line Number

  7. Sometimes if directly compy&paste codes from a text editor, the indentation may be troublesome:
    Select the cell with problematic indentations, hit Tab to indent, then hit Shift + Tab to inverse indentation.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值