A model is a data structure that consists of Layers and defines inputs
and outputs.
The key difference between tf.model and tf.sequential is that
tf.model is more generic, supporting an arbitrary graph (without
cycles) of layers. tf.sequential is less generic and supports only a linear
stack of layers.
When creating a tf.LayersModel, specify its input(s) and output(s). Layers
are used to wire input(s) to output(s).
For example, the following code snippet defines a model consisting of
two dense layers, with 10 and 4 units, respectively.
// Define input, which has a size of 5 (not including batch dimension). constinput = tf.input({shape: [5]});
// Obtain the output symbolic tensor by applying the layers on the input. constoutput = denseLayer2.apply(denseLayer1.apply(input));
// Create the model based on the inputs. constmodel = tf.model({inputs:input, outputs:output});
// The model can be used for training, evaluation and prediction. // For example, the following line runs prediction with the model on // some fake data. model.predict(tf.ones([2, 5])).print();
A model is a data structure that consists of
Layers
and defines inputs and outputs.The key difference between
tf.model
andtf.sequential
is thattf.model
is more generic, supporting an arbitrary graph (without cycles) of layers.tf.sequential
is less generic and supports only a linear stack of layers.When creating a
tf.LayersModel
, specify its input(s) and output(s). Layers are used to wire input(s) to output(s).For example, the following code snippet defines a model consisting of two
dense
layers, with 10 and 4 units, respectively.See also:
tf.sequential
,tf.loadLayersModel
.