To implement training routines beyond supervised learning That you can easily customize these loops The Model class offers a built-in training loop (the fit() method)Īnd a built-in evaluation loop (the evaluate() method). Training, evaluation, and inference work exactly in the same way for modelsīuilt using the functional API as for Sequential models. The connection arrows are replaced by the call operation.Ī "graph of layers" is an intuitive mental image for a deep learning model,Īnd the functional API is a way to create models that closely mirrors this. This figure and the code are almost identical. In the plotted graph: _model(model, "my_first_model_with_shape_info.png", show_shapes=True) You can also plot the model as a graph: _model(model, "my_first_model.png")Īnd, optionally, display the input and output shapes of each layer Let's check out what the model summary looks like: model.summary() In the graph of layers: model = keras.Model(inputs=inputs, outputs=outputs, name="mnist_model") Let's add a few more layers to the graph of layers: x = layers.Dense(64, activation="relu")(x)Īt this point, you can create a Model by specifying its inputs and outputs You're "passing" the inputs to the dense layer, and you get x as the output. The "layer call" action is like drawing an arrow from "inputs" to this layer Object: dense = layers.Dense(64, activation="relu") You create a new node in the graph of layers by calling a layer on this inputs Of the input data that you feed to your model. The inputs that is returned contains information about the shape and dtype You would use: # Just for demonstration purposes. If, for example, you have an image input with a shape of (32, 32, 3), The batch size is always omitted since only the shape of each sample is specified. The shape of the data is set as a 784-dimensional vector. To build this model using the functional API, start by creating an input node: inputs = keras.Input(shape=(784,)) (output: logits of a probability distribution over 10 classes)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |