Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help finding out what to code for the mini-batch gradient Descent function. PYTHON CODE Update: Is there any other information required to receive help

Need help finding out what to code for the mini-batch gradient Descent function. PYTHON CODE

Update: Is there any other information required to receive help for this question?

X = x_train.iloc[:, :] y = np.array(pd.DataFrame(y_train.values)) #.values converts it from pandas.core.frame.DataFrame to numpy.ndarray theta = np.zeros([1, X.shape[1]]) print(X.shape, y.shape, theta.shape)

# Let's define a cost function... def cal_cost(theta, X, y): ''' Calculates the cost for given X and Y. The following shows and example of a single dimensional X theta = Vector of thetas

''' m = len(y) predictions = X.dot(theta) cost = (1/2*m) * np.sum(np.square(predictions-y)) return cost

def minibatch_gradient_descent(X,y,theta,learning_rate=0.01,iterations = 10,batch_size =50): ''' X = Matrix of X without added bias units y = Vector of Y TO DO: Return the final theta vector and array of cost history over iterations '''

cost_history = np.zeros(iterations)

""" TO DO: Implement code for Minibatch Gradient Descent """

return theta, cost_history

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

Step: 3

blur-text-image

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions