Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use TensorFlow to predict the next output from a given set of random inputs. Start by importing the necessary libraries. Use Numpy along with TensorFlow

Use TensorFlow to predict the next output from a given set of random inputs. Start by importing the necessary libraries. Use Numpy along with TensorFlow for computations and Matplotlib for plotting.

import numpy as np

import tensorflow as tf

import matplotlib.pyplot as plt

In order to make the random numbers predictable, we will define fixed seeds for both Numpy and TensorFlow.

np.random.seed(101)

tf.set_random_seed(101)

Now, lets generate some random data for training the Linear Regression Model.

# Generating random linear data

# There will be 50 data points ranging from 0 to 50

x = np.linspace(0, 50, 50)

y = np.linspace(0, 50, 50)

# Adding noise to the random linear data

x += np.random.uniform(-4, 4, 50)

y += np.random.uniform(-4, 4, 50)

n = len(x) # Number of data points

Complete the following steps:

1) Plot the training data.

2) Create a TensorFlow model by defining the placeholders X and Y so that you can feed your training examples X and Y into the optimizer during the training process.

3) Declare two trainable TensorFlow variables for the weights and bias and initialize them randomly.

4) Define the hyperparameters for the model:

learning_rate = 0.01

training_epochs = 1000

5) Implement Python code for:

the hypothesis,

the cost function,

the optimizer.

6) Implement the training process inside a TensorFlow session.

7) Print out the results for the training cost, weight, and bias.

8) Plot the fitted line on top of the original data.

9) Please provide screenshots of your plots

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions