2 Getting Started: Simple Linear Regression in TensorFlow.js

 

This chapter covers

  • A minimal example of neural network, for the simple machine-learning task of linear regression
  • Tensors and tensor operations
  • Basic neural-network optimization

Nobody likes to wait, and it's especially annoying to wait when we don't know how long we'll have to wait for. Any UX designer will tell you that if you can't hide the delay, then the next best thing is to give the user a reliable estimate of wait time. Estimating expected delays is a prediction problem, and the TensorFlow.js library can be used to build an accurate download-time prediction, sensitive to the context and user, enabling us to build clear, reliable experiences that respect the user's time and attention.

In this chapter, using a simple download-time prediction problem as our motivating example, we will introduce the main components of a complete machine learning model. We will cover tensors, modeling, and optimization from a practical point of view. We will build intuitions about what they are, how they work, and how to use them appropriately.

2.1  Example 1: Predicting the duration of a download using TensorFlow.js

2.1.1  Project Overview : Duration Prediction

2.1.2  A note on code listings and console interactions

2.1.3  Creating and formatting the data

2.1.4  Defining a simple model

2.1.5  Fitting the model to the training data

2.1.6  Using our trained model to make predictions

2.1.7  Summary of our first example

2.2  Inside Model.fit(): Dissecting gradient descent from Example 1

2.2.1  The intuitions behind gradient descent optimization

2.2.2  Backpropagation: Inside gradient descent

2.3  Linear regression with multiple input features

2.3.1  The Boston Housing Prices dataset

2.3.2  Getting and running the Boston-housing project from GitHub

2.3.3  Accessing the Boston-housing data

2.3.4  Precisely defining the Boston-housing problem

2.3.5  A slight diversion into data normalization