March 2019
Intermediate to advanced
532 pages
13h 2m
English
The linear_regression_keras_training.py dataset performs the training of a linear regression model. The first step is to create the data to be used for training/testing the algorithm as follows:
# Generate random data composed by 50 (N = 50) points:x = np.linspace(0, N, N)y = 3 * np.linspace(0, N, N) + np.random.uniform(-10, 10, N)
The next step is to create the model. To do so, we have created the create_model() function, as demonstrated in the following code snippet:
def create_model(): """Create the model using Sequencial model""" # Create a sequential model: model = Sequential() # All we need is a single connection so we use a Dense layer with linear activation: model.add(Dense(input_dim=1, units=1, activation ...