tf.keras.experimental.LinearModel

Linear Model for regression and classification problems.

Inherits From: Model, Layer, Module

This model approximates the following function:

$$y = \beta + \sum_{i=1}^{N} w_{i} * x_{i}$$

where

$$\beta$$

is the bias and

$$w_{i}$$

is the weight for each feature.

Example:

model = LinearModel()
model.compile(optimizer='sgd', loss='mse')
model.fit(x, y, epochs=epochs)

This model accepts sparse float inputs as well:

Example:

model = LinearModel()
opt = tf.keras.optimizers.Adam()
loss_fn = tf.keras.losses.MeanSquaredError()
with tf.GradientTape() as tape:
  output = model(sparse_input)
  loss = tf.reduce_mean(loss_fn(target, output))
grads = tape.gradient(loss, model.weights)
opt.apply_gradients(zip(grads, model.weights))

units Positive integer, output dimension without the batch size.
activation Activation function to use. If you don't specify anything, no activation is applied.
use_bias whether to calculate the bias/intercept for this model. If set to False, no bias/intercept will be used in calculations, e.g., the data is already centered.
kernel_initializer Initializer for the