This topic describes how to develop deep learning networks in a visualized manner.

Background information

Neural networks were first introduced to the biology field to study the complicated structure of biological neurons. Multiple mathematical formulas were later used to simulate how the brain analyzes objects. This formed the basis for deep learning frameworks.

You can build deep learning networks through coding. However, a complex deep learning network contains tens or even hundreds of lines of code, and each network layer consists of multiple parameters, as shown in the following figure. After the number of network layers increases, it becomes more difficult to build a deep learning network through coding and the costs for maintaining the deep learning network also increase.Traditional deep learning network
The FastNeuralNetwork feature of Data Science Workshop (DSW) allows you to covert code for deep learning on graphs into a network architecture graph and supports graph editing. This improves model readability and makes it easier for you to maintain models.Deep learning overview

Use preset cases

If you are a first-time user of DSW, we recommend that you use preset cases to familiarize yourself with the procedure of how to develop deep learning networks in a visualized manner.

  1. Download the preset case FNNDemo to build a deep learning network.
    1. In the left-side navigation pane of the Data Science Workshop page, click the Preset case icon icon.
    2. Click the Download a preset case icon next to FNNDemo.
      The downloaded case is stored in the /Demo/Cases path.
  2. Open the FNNDemo file.
    1. In the left-side navigation pane, click the Folder icon icon.
    2. Switch to the /Demo path.
      You can switch to the path by using one of the following methods:
      • Double-click Demo in the Name column.
      • Right-click Demo in the Name column. In the shortcut menu that appears, click Open.
    3. Switch to the /Demo/Cases path.
      You can switch to the path by using one of the following methods:
      • Double-click Cases in the Name column.
      • Right-click Cases in the Name column. In the shortcut menu that appears, click Open.
    4. Switch to the /demo/cases/FNNDemo path.
      You can switch to the path by using one of the following methods:
      • Double-click FNNDemo in the Name column.
      • Right-click FNNDemo in the Name column. In the shortcut menu that appears, click Open.
    5. Open the downloaded case.
      You can open the file by using one of the following methods:
      • Double-click the file in the Name column.
      • Right-click the file in the Name column. In the shortcut menu that appears, click Open.
  3. Edit the deep learning network by modifying the sample code. Then, save the changes. For more information, see Step 4 and Step 5 in the Custom network development section.

Custom network development

The FastNeuralNetwork feature of DSW supports the following development modes:
  • Keras Code: Write deep learning network code and convert the code into a graph.
  • Keras Graph: Build a deep learning network on the canvas and convert the graph to code.
Keras Code is used as an example in this topic to describe how to develop deep learning networks in a visualized manner.
  1. Click the KerasCode icon icon to create a .ipynb file.Create KerasCode
  2. On the interactive development page, build a deep learning network.
    1. The following sample code is used to build the deep learning network:
      import keras
      from keras.models import Model
      from keras.models import Sequential
      from keras.layers import Conv2D, Dense, MaxPooling2D, Flatten, Dropout
      from keras.initializers import VarianceScaling, Zeros
      model = Sequential()
      model.add(MaxPooling2D(padding='valid', data_format='channels_last', pool_size=(2, 2), strides=(2, 2), trainable=True))
      model.add(Conv2D(dilation_rate=(1, 1), padding='valid', data_format='channels_last', bias_initializer=Zeros(), use_bias=True, filters=64, strides=(1, 1), trainable=True, kernel_initializer=VarianceScaling(mode='fan_avg', seed=None, scale=1.0, distribution='uniform'), activation='relu', kernel_size=(3, 3)))
      model.add(MaxPooling2D(padding='valid', data_format='channels_last', pool_size=(2, 2), strides=(2, 2), trainable=True))
      model.add(Dropout(rate=0.25, trainable=True))
      model.add(Flatten(data_format='channels_last', trainable=True))
      model.add(Dense(bias_initializer=Zeros(), use_bias=True, units=128, trainable=True, kernel_initializer=VarianceScaling(mode='fan_avg', seed=None, scale=1.0, distribution='uniform'), activation='relu'))
      model.add(Dropout(rate=0.4, trainable=True))
      model.add(Dropout(rate=0.2))
      A Sequential model is created in this topic with model as the object.
    2. Run the magic command to convert the code into a graph.
      %show_model model
      Deep learning network graph
    3. Click the graph to open the graph editing page.The graph editing page
  3. Edit the deep learning network.
    The FNN feature allows you to drag and drop native Keras cells to the canvas, and edit the cells. The graph editing page contains the cell list in the left, canvas in the middle, and the parameter setting section in the right.
    Cells of the same function are connected, as shown in the following figure.Automatic orchestration
    The cells in the canvas are automatically mapped to the code, as shown in the following figure.Automatic code mappingTo delete a cell or a connection in the canvas, select the code of the cell or connection, and press the Backspace key.
  4. Save code changes.
    1. On the top of the canvas, click To Code. In the Diff Editor dialog box, the modification details are displayed.Code comparison
    2. Click OK to apply the code changes to the file.