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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.