Model Training

Now we will train our model using the training and validation pipeline.

Python3




history = model.fit(train_ds,
                    epochs=50,
                    validation_data=val_ds)


Output:

Epoch 45/50
10/10 [==============================] - 0s 14ms/step - loss: 2.8792 - mape: 12.5425 - val_loss: 5.3991 - val_mape: 28.6586
Epoch 46/50
10/10 [==============================] - 0s 8ms/step - loss: 2.9184 - mape: 12.7887 - val_loss: 4.1896 - val_mape: 21.4064
Epoch 47/50
10/10 [==============================] - 0s 9ms/step - loss: 2.8153 - mape: 12.3451 - val_loss: 4.3392 - val_mape: 22.3319
Epoch 48/50
10/10 [==============================] - 0s 9ms/step - loss: 2.7146 - mape: 11.7684 - val_loss: 3.6178 - val_mape: 17.7676
Epoch 49/50
10/10 [==============================] - 0s 10ms/step - loss: 2.7631 - mape: 12.1744 - val_loss: 6.4673 - val_mape: 33.2410
Epoch 50/50
10/10 [==============================] - 0s 10ms/step - loss: 2.6819 - mape: 11.8024 - val_loss: 6.0304 - val_mape: 31.6198

Python3




history_df = pd.DataFrame(history.history)
history_df.head()


Output:

 

Python3




history_df.loc[:, ['loss', 'val_loss']].plot()
history_df.loc[:, ['mape', 'val_mape']].plot()
plt.show()


Output:

 

The training error has gone down smoothly but the case with the validation is somewhat different.



Predict Fuel Efficiency Using Tensorflow in Python

In this article, we will learn how can we build a fuel efficiency predicting model by using TensorFlow API. The dataset we will be using contain features like the distance engine has traveled, the number of cylinders in the car, and other relevant feature.

Similar Reads

Importing Libraries

Pandas – This library helps to load the data frame in a 2D array format and has multiple functions to perform analysis tasks in one go. Numpy – Numpy arrays are very fast and can perform large computations in a very short time. Matplotlib – This library is used to draw visualizations. Sklearn – This module contains multiple libraries having pre-implemented functions to perform tasks from data preprocessing to model development and evaluation. OpenCV – This is an open-source library mainly focused on image processing and handling. Tensorflow – This is an open-source library that is used for Machine Learning and Artificial intelligence and provides a range of functions to achieve complex functionalities with single lines of code....

Exploratory Data Analysis

...

Data Input Pipeline

...

Model Architecture

...

Model Training

...