Algorithms For Dummies. John Paul Mueller

Чтение книги онлайн.

Читать онлайн книгу Algorithms For Dummies - John Paul Mueller страница 25

Algorithms For Dummies - John Paul Mueller

Скачать книгу

text cells

      Notice the menu to the right of the text cell. This menu contains many of the same options that a code cell does. For example, you can create a list of links to help people access specific parts of your notebook through an index. In contrast to Notebook, you can’t execute text cells to resolve the markup they contain.

      Creating special cells

      The special cells that Colab provides are variations of the text cell. These special cells, which you access using the Insert menu option, make creating the required cells faster. However, you shouldn’t use these special cells if you need to maintain compatibility between Colab and Notebook. The following sections describe each of these special cell types.

      Working with headings

      When you choose Insert ⇒ Section Header Cell, you see a new cell created below the currently selected cell that has the appropriate header level 1 entry in it. You can increase the heading level by clicking the double T icon. The GUI looks the same as the one in Figure 3-10, so you have all the standard formatting features for your text.

Snapshot shows Use the GUI to make formatting your text easier.

      FIGURE 3-10: Use the GUI to make formatting your text easier.

      Working with a table of contents

      An interesting addition to Colab is the automatic generation of a table of content for your notebook. To use this feature, click the Table of Contents icon on the left side of the window. The table of contents contains one entry for each heading you provide in your code. The entries are automatically organized according to level, so you see the hierarchy of your code. Clicking an entry automatically takes you to that location in your code.

      Editing cells

      Both Colab and Notebook have Edit menus that contain the options you expect, such as the ability to cut, copy, and paste cells. The two products also have some interesting differences. For example, Notebook allows you to split and merge cells. Colab contains an option to show or hide the code as a toggle. These differences give each product a slightly different flavor but don’t really change your ability to use each one to create and modify Python code.

      Moving cells

      The same technique you use for moving cells in Notebook also works with Colab. The only difference is that Colab relies exclusively on toolbar buttons (refer to in Figure 3-9); Notebook also has cell movement options on the Edit menu. To move a cell, select it and then click the Move cell up or Move cell down buttons as needed.

      Even though you won’t need it for the examples in this book, Colab does offer hardware acceleration in the form of a Graphics Processing Unit (GPU) or Tensor Processing Unit (TPU). Both of these special processors offer the ability to process multiple sets of data in parallel at high speed. When working with big data (see Chapter 12) in a machine learning or deep learning environment, a GPU or TPU can make a huge difference in the time required to accomplish a task. The main difference between a GPU and a TPU is that a GPU appears as part of most high-end display adapters today and can double for rendering complex graphics, while a TPU is a custom processor designed by Google specifically for machine learning and deep learning tasks. (There are other differences, but they aren’t important for this book.)

      For your code to be useful, you need to run it at some point. Previous sections have mentioned the right-pointing arrow that appears in the current cell. Clicking it runs just the current cell. Of course, you have other options than clicking the right-pointing arrow, and all these options appear on the Runtime menu (the Cell menu in Notebook). The following list summarizes these options:

       Running the current cell: Instead of clicking the right-pointing arrow, you can also choose Runtime ⇒ Run the Focused Cell to execute the code in the current cell.

       Running other cells: Colab provides options on the Runtime menu for executing the code in the next cell, the previous cell, or a selection of cells. Simply choose the option that matches the cell or set of cells you want to execute.

       Running all the cells: In some cases, you want to execute all the code in a notebook. In this case, choose Runtime ⇒ Run All. Execution starts at the top of the notebook, in the first cell containing code, and continues to the last cell that contains code in the notebook. You can stop execution at any time by choosing Runtime ⇒ Interrupt Execution.

      

Choosing Runtime ⇒ Manage Sessions displays a dialog box containing a list of all the sessions that are currently executing for your account on Colab. You can use this dialog box to determine when the code in that notebook last executed and how much memory the notebook consumes. Click the trash can icon to end execution for a particular notebook.

      The most obvious place to obtain help with Colab is from the Colab Help menu. The menu doesn't have a general help link, but you can find it at https://colab.research.google.com/notebooks/welcome.ipynb (which requires you to log into the Colab site). This menu does contain all the usual entries:

       Frequently Asked Questions (FAQs): Takes you to a page containing questions that other people have asked.

       Search Code Snippets: Opens a pane showing common tasks, such as working with a camera, in which you can search for example code that could meet your needs with a little modification. Clicking the Insert button inserts the code at the current cursor location in the cell that has focus. Each of the entries also shows an example of the code.

       Report a Bug: Takes you to a page where you can report Colab errors.

       Ask a Question on Stack Overflow: Displays a new browser tab, where you can ask questions from other users. You see a login screen if you haven’t already logged in to Stack Overflow.

Скачать книгу