Created
May 28, 2022 03:43
-
-
Save esenthil2018/4ee466d1ef11163ebd78633c0a3a5fe5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Linear regression Model | |
linear_model = tf.keras.Sequential([ | |
normalizer, | |
layers.Dense(units=1) | |
]) | |
linear_model.predict(train_features1[:10]) | |
linear_model.layers[1].kernel | |
linear_model.compile( | |
optimizer=tf.optimizers.Adam(learning_rate=0.1), | |
loss='mean_absolute_error') | |
history = linear_model.fit( | |
train_features1, | |
train_labels1, | |
epochs=100, | |
# Suppress logging. | |
verbose=0, | |
# Calculate validation results on 20% of the training data. | |
validation_split = 0.2) | |
def plot_loss(history): | |
plt.plot(history.history['loss'], label='loss') | |
plt.plot(history.history['val_loss'], label='val_loss') | |
plt.ylim([0, 10]) | |
plt.xlabel('Epoch') | |
plt.ylabel('Error [MPG]') | |
plt.legend() | |
plt.grid(True) | |
plot_loss(history) | |
test_results = {} | |
test_results['linear_model'] = linear_model.evaluate( | |
test_features1, test_labels1, verbose=0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment