Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!