In this article, we will discuss Jupyter Notebooks on E2E TIR AI Platform which is an IDE used for python programming.
There are various editing tools in which we can program python in. Python is an object oriented programming language that uses an interpreter as opposed to a compiler. The major difference between interpreter and compiler is that compiler goes through the whole program at once and interpreter stops at a point where it encounters an error. In such cases it becomes time taking to debug and execute the python program. Jupyter notebook makes it easier to debug errors via cells one by one and the user gets a clear understanding of where they are going wrong. This is why Jupyter Notebooks are so popular.
What Are Jupyter Notebooks?
Jupyter Notebook is a user-friendly and interactive Integrated Development Environment (IDE) which is used for python and R programming. It is widely used by data scientists and python programmers. It is a great tool for beginners who want to get started with python. It is mostly used for visualization purposes and allows debugging in a simple way.
How To Use Jupyter Notebooks? - A Complete Guide
- Installation process
In order to use jupyter notebooks on E2E Cloud, we need to click on TIR-AI Platform on top of our dashboard.
We will be navigated to the below screen.
- Getting started with Jupyter Notebook
To get started with Jupyter Notebook, we need to create a notebook image as depicted in the screenshot below:.
Here, we have selected the free tier CPU Machine to run our notebook on.
- Creating a new notebook
On clicking create, the notebook will be created in a couple of seconds.
The notebook is running now.
Click on tir-notebook-27. And you will be redirected to the following page:
Under notebook , click Python3 and your notebook will be created.
- Writing a program to convert english to german using flan-t5-base in Jupyter Notebook
- First, we need to clone the huggingface repo using the following command:
git clone https://huggingface.co/google/flan-t5-base
And, install the transformers library using pip.
- Then, paste the following code snippet in the cell of the jupyter notebook:
- Then we hit the play button or hit shift+ enter.
and , we receive the output.
- The same process is tried for a different input text and we receive the correct output.
- Understanding cells in Jupyter Notebook
In a Jupyter Notebook, a cell either holds code or markdown text. Once the code is entered in the cell and executed, the output is displayed below the cell. When the cell is in markdown mode, it formats the text in the cell in .md format. This allows easy readability and helps understand what the notebook deals with.
- Exploring the kernel
The kernel is responsible for running the cells in the notebook. When you want to interrupt the running of a cell you can stop the kernel or hit pause. To restart the kerner you can press the play button on the menu bar.
- Naming your notebook
Initially, the name of the notebook is untitled.ipynb as shown below:
You can edit the untitled to any name of your choice. For example “sample_notebook”.
- Utilizing notebook extensions
You can save the notebook in various formats:
Shortcuts in Jupyter Notebooks
Here is a list of some commonly used shortcuts in Jupyter Notebook:
1. Command Mode Shortcuts (Press Esc to enter Command Mode):
- Enter: Enter Edit Mode (to edit the content of a cell)
- Shift + Enter: Run the current cell and select the cell below
- Ctrl + Enter: Run the current cell
- A: Insert a new cell above the current cell
- B: Insert a new cell below the current cell
- D, D (press D twice): Delete the current cell
- Y: Change the cell type to Code
- M: Change the cell type to Markdown
- Up Arrow / K: Select the cell above
- Down Arrow / J: Select the cell below
2. Edit Mode Shortcuts (Press Enter to enter Edit Mode):
- Ctrl + /: Comment/uncomment selected lines
- Tab: Code completion or indent selection
- Shift + Tab: Show tooltip or function signature
- Ctrl + A: Select all
- Ctrl + Z: Undo
- Ctrl + Y: Redo
- Ctrl + C: Copy selected cells
- Ctrl + X: Cut selected cells
- Ctrl + V: Paste cells below
- Ctrl + Shift + V: Paste cells above
- Ctrl + S: Save the notebook
3. General Shortcuts:
- Shift + Tab (after function name): Show tooltip or function signature
- Esc: Switch to Command Mode
- Enter: Switch to Edit Mode
- H: Show keyboard shortcuts help dialog
- 0, 0 (press 0 twice): Restart the kernel
- I, I (press I twice): Interrupt the kernel
- Spacebar: Scroll notebook down
- Shift + Spacebar: Scroll notebook up
Conclusion
In this article we have covered all the aspects of jupyter notebooks on the E2E TIR-AI platform. What they are and how to use them. Hopefully, one must have now gotten a clear idea of how to run python programs for their applications. It is mostly used in data science because of its awesome visualization capabilities. Drop in the comments below how you use jupyter notebooks in your day-to-day life.