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

 PLEASE WRITE THE GRADIENT FUNCTION AND THE GRADIENT DESCENT FUNCTION. Donot use loops for the gradient function; use vectorized gradient descent. Ihave included the date (tiny_training.csv), the other functions, the pytest, and theequations from the notes! Everything you need is here. \# you canuse 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) fora number of iterations. Prints training cost and validation cost (if df_valis not None) every 50 iterations. Returns: emb_user: the trained user embeddingemb_movie: the trained movie embedding IIII Y=df2matrix(df, emb_user.shape[0], emb_movie.shape [0]) \#\#\# BEGIN

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

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!