Wide & Deep Model for regression and classification problems.

Inherits From: Model, Layer, Module

This model jointly train a linear and a dnn model.


linear_model = LinearModel()
dnn_model = keras.Sequential([keras.layers.Dense(units=64),
combined_model = WideDeepModel(linear_model, dnn_model)
combined_model.compile(optimizer=['sgd', 'adam'], 'mse', ['mse'])
# define dnn_inputs and linear_inputs as separate numpy arrays or
# a single numpy array if dnn_inputs is same as linear_inputs.[linear_inputs, dnn_inputs], y, epochs)
# or define a single `` that contains a single tensor or
# separate tensors for dnn_inputs and linear_inputs.
dataset =[linear_inputs, dnn_inputs], y)), epochs)

Both linear and dnn model can be pre-compiled and trained separately before jointly training:


linear_model = LinearModel()
linear_model.compile('adagrad', 'mse'), y, epochs)
dnn_model = keras.Sequential([keras.layers.Dense(units=1)])
dnn_model.compile('rmsprop', 'mse'), y, epochs)
combined_model = WideDeepModel(linear_model, dnn_model)
combined_model.compile(optimizer=['sgd', 'adam'], 'mse', ['mse'])[linear_inputs, dnn_inputs], y, epochs)

linear_model a premade LinearModel, its output must match the output of the dnn model.
dnn_model a tf.keras.Model, its output must match the output of the linear model.
activation Activation function. Set it to None to maintain a linear activation.
**kwargs The keyword arguments that are passed on to BaseLayer.init. Allowed keyword arguments include name.

distribute_strategy The tf.distribute.Strategy this model was created under.

metrics_names Returns the model's display labels for all outputs.

inputs = tf.keras.layers.Input(shape=(3,))
outputs = tf.keras.layers.Dense(2)(inputs)
model = tf.keras.models.Model(inputs=inputs, outputs=outputs)
model.compile(optimizer="Adam", loss="mse", metrics=["mae"])
x = np.random.random((2, 3))
y = np.random.randint(0, 2, (2, 2)), y)
['loss', 'mae']
inputs = tf.keras.layers.Input(shape=(3,))
d = tf.keras.layers.Dense(2, name='out')
output_1 = d(inputs)
output_2 = d(inputs)
model = tf.keras.models.Model(
   inputs=inputs, outputs=[output_1, output_2])
model.compile(optimizer="Adam", loss="mse", metrics=["mae", "acc"]), (y, y))
['loss', 'out_loss', 'out_1_loss', 'out_mae', 'out_acc', 'out_1_mae',

run_eagerly Settable attribute indicating whether the model should run eagerly.

Running eagerly means that your model will be run step by step, like Python code. Your model might run slower, but it should become easier for you to debug it by stepping into individual layer calls.

By default, we will attempt to compile your model to a static graph to deliver the best execution performance.



View source

Calls the model on new inputs.

In this case call just reapplies all ops in the graph to the new inputs (e.g. build a new computational graph from the provided inputs).

inputs Input tensor, or dict/list/tuple of input tensors.
training <