This article explains how to create Regression
Model in TensorFlow
using tf.keras.Sequential
.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow.keras import layers
Pandas DataFrame
abalone_train = pd.read_csv(
"https://storage.googleapis.com/download.tensorflow.org/data/abalone_train.csv",
names=["Length", "Diameter", "Height", "Whole weight", "Shucked weight",
"Viscera weight", "Shell weight", "Age"])
abalone_features = abalone_train.copy()
abalone_labels = abalone_features.pop('Age')
numpy
abalone_features = np.array(abalone_features)
Regression
model to predict the age
abalone_model = tf.keras.Sequential([
layers.Dense(64),
layers.Dense(1)
])
abalone_model.compile(loss = tf.losses.MeanSquaredError(),
optimizer = tf.optimizers.Adam())
abalone_model.fit(abalone_features, abalone_labels, epochs=10)
Category: TensorFlow