Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE WRITE THE GRADIENT FUNCTION AND THE GRADIENT DESCENT FUNCTION. Do not use loops for the gradient function; use vectorized gradient descent. I have included

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

PLEASE WRITE THE GRADIENT FUNCTION AND THE GRADIENT DESCENT FUNCTION. Do not use loops for the gradient function; use vectorized gradient descent. I have included the date (tiny_training.csv), the other functions, the pytest, and the equations from the notes! Everything you need is here.

\# you can use a for loop to iterate through gradient descent def gradient_descent(df, emb_user, emb_movie, iterations=100, learning_rate=0.01, df_val=None): "II" Computes gradient descent with momentum (0.9) for a number of iterations. Prints training cost and validation cost (if df_val is not None) every 50 iterations. Returns: emb_user: the trained user embedding emb_movie: the trained movie embedding IIII Y=df2matrix(df, emb_user.shape[0], emb_movie.shape [0]) \#\#\# BEGIN SOLUTION \#\#\# END SOLUTION return emb_user, emb_movie [7]: emb_movie [7]: array([[0.66095748,0.84977739,0.34908569,0.61299313,1.07153635], [1.07555171,0.15070237,0.24869145,0.06176064,0.52897181], [0.03585145,0.54819987,0.77897286,0.33418474,0.81150588], [0.70903538,0.02877826,0.67062491,0.31110294,0.49812144]]) [8]: emb_user [8] : array([[0.66095748,0.84977739,0.34908569,0.61299313,1.07153635], [1.07555171,0.15070237,0.24869145,0.06176064,0.52897181], [0.03585145,0.54819987,0.77897286,0.33418474,0.81150588], [0.70903538,0.02877826,0.67062491,0.31110294,0.49812144], [0.3402301,0.8317655,0.52854446,0.18824129,0.65357882], [0.93637772,0.36763624,0.26634946,0.46556551,1.12366038], [1.17119451,0.80686041,1.08340093,1.01490105,0.45359285]]) [ ] : 123456789101112131415userId,movieId,rating11,1,411,23,52,23,52,4,331,1,431,23,44,1,54,3,252,1,152,3,461,3,57,23,17,3,3 uE=N2vvE=N2u

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions