2

Vanishing Gradient Detection

Unsolved
Fundamentals
Optimization

Difficulty: 2 | Problem written by zeyad_omar
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

Gradient descent is an optimization algorithm that aims at finding the best weights that result in the least error by subtracting a small value from the previously calculated gradient (a step towards minimizing the error function). This step size is known as learning rate (alpha).

In some cases, the previous gradients are so small that when we multiply it by alpha, the effect of change to the model weights are negligible. Therefore, the weights are unchanged at each learning step and nothing is learned.

In this problem, you are given a 1D vector of gradients. Your task is return the indices of all gradients that might lead to the vanishing gradients problem (by comparing them with a threshold value)

 

Sample Input:
<class 'list'>
grads: [1.01, 0.9, 1.56, 10.2, 30.25]
<class 'float'>
threshold: 0.05

Expected Output:
<class 'list'>
[]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Nostrum dignissimos itaque consequuntur placeat rem. Modi similique libero officiis assumenda eos minus perspiciatis distinctio deleniti, perferendis consequatur nemo id ullam explicabo unde est, recusandae eveniet reprehenderit quisquam tenetur, ad dolores saepe deleniti nisi, voluptate beatae culpa eveniet molestias odit officia voluptatibus?

Ipsam pariatur possimus, ex harum nostrum cupiditate porro eum iure quis aperiam maxime debitis, mollitia dolores maiores saepe modi nobis, nobis nihil reiciendis illo totam tenetur amet nisi sapiente? Mollitia animi reprehenderit sint delectus in repudiandae provident veniam harum non, aperiam aut voluptates neque aliquam harum ipsa, earum maxime rerum accusantium illum corrupti repudiandae, neque cumque eum impedit, deserunt ab incidunt expedita optio illum error sed earum id voluptates?

Deleniti necessitatibus voluptatum earum a assumenda neque reprehenderit soluta atque.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)