Implementing a logistic regression model with the Layers API

Using the Core API allows you to construct the model in a flexible manner. Ideally, you can build any type of machine learning model that you like if you have a mathematical understanding of the model. However, in some cases, you may want to build a simple model such as logistic regression without writing much code.

The Layers API is an intuitive way to strike a good balance between flexibility and convenience. In this section, we are going to look into the implementation of logistic regression using the Layers API. The logistic regression model can be described as a single-layer neural network that has a single output connected to the input vector:

The input vector has (D+1) ...

Get Hands-On Machine Learning with TensorFlow.js now with O’Reilly online learning.

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