Defining models with tf.layers

As shown in the previous section, TensorFlow provides all the primitive features to define a neural network layer: the user should take care when defining the variables, the operation nodes, the activation functions, and the logging, and define a proper interface to handle all cases (adding, or not, the bias term, adding regularization to the layer parameters, and so on).

The tf.layers module in TensorFlow 1.x and the tf.keras.layers module in TensorFlow 2.0 provide an excellent API to define machine learning models in a convenient and powerful way. Every layer in tf.layers, defines variables using tf.get_variable, and therefore, each layer defined in this way can use the variable-sharing features provided ...

Get Hands-On Neural Networks with TensorFlow 2.0 now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.