官术网_书友最值得收藏!

Deep learning layers

In the earlier code snippets, we saw some layers for a deep learning model, including mx.symbol.FullyConnected, mx.symbol.Activation, and mx.symbol.Dropout. Layers are how models are constructed; they are computational transformations of data. For example, mx.symbol.FullyConnected is the first type of layer operation we matrix operation we introduced in Chapter 1, Getting Started with Deep LearningIt is fully connected because all input values are connected to all nodes in the layer. In other deep learning libraries, such as Keras, it is called a dense layer. 

The mx.symbol.Activation layer performs an activation function on the output of the previous layer. The mx.symbol.Dropout layer performs dropout on the output from the previous layer. Other common layer types in MXNet are:

  • mxnet.symbol.Convolution: Performs a convolutional operation that matches patterns across the data. It is mostly used in computer vision tasks, which we will see in Chapter 5, Image Classification Using Convolutional Neural Networks. They can also be used for Natural Language Processing, which we will see in Chapter 6, Natural Language Processing Using Deep Learning.
  • mx.symbol.Pooling: Performs pooling on the output from the previous layer. Pooling reduces the number of elements by taking the average, or max value, from sections of the input. These are commonly used with convolutional layers.
  • mx.symbol.BatchNorm: Used to normalize the weights from the previous layer. This is done for the same reason you normalize input data before model-building: it helps the model to train better. It also prevents vanishing and exploding gradients where gradients get very, very small or very, very large during training. This can cause the model to fail to converge, that is, training will fail.
  • mx.symbol.SoftmaxOutput: Calculates a softmax result from the output from the previous layer.

There are recognized patterns for using these layers, for example, an activation layer normally follows a fully-connected layer. A dropout layer is usually applied after the activation function, but can be between the fully connected layer and the activation function. Convolutional layers and pooling layers are often used together in image tasks in that order. At this stage, there is no need to try to memorize when to use these layers; you will encounter plenty of examples in the rest of this book!

If all this seems confusing, take some comfort in knowing that a lot of the difficult work in applying these layers is abstracted away from you. In the previous chapter, when we built a neural network, we had to manage all the input output from the layers. This meant ensuring that the matrix dimensions were correct so that the operations worked. Deep Learning libraries, such as MXNet and TensorFlow, take care of this for you.
主站蜘蛛池模板: 高唐县| 安图县| 永寿县| 潜山县| 镇宁| 柞水县| 澄江县| 无棣县| 丰台区| 台南市| 宜昌市| 大庆市| 都兰县| 许昌县| 甘孜县| 沛县| 攀枝花市| 张家川| 马龙县| 葵青区| 清流县| 石城县| 廉江市| 郴州市| 苍南县| 通州市| 遂平县| 黎川县| 灌阳县| 武城县| 金寨县| 广灵县| 渑池县| 景泰县| 威远县| 吴桥县| 南川市| 巧家县| 吴江市| 高唐县| 昌都县|