Question: Which piece of code would apply stochastic gradient descent for 1 0 iterations on the formula: y = x * * * * 2 +

Which piece of code would apply stochastic gradient descent for 10 iterations on the
formula: y=x****2+x, where x is a tensor of shape (1,2)
A:
x=tf.Variable(tf.random.uniform([1,2]))
optimizer = tf.optimizers.SGD()
for i in range (0,10) :
with tf.GradientTape() as tape:
y=tf.add(tf.(x),x)
optimizer.apply_gradients([(gradients, x)])
gradients = tape. gradient(y,x)
B:
x=tf. Variable (tf.random.uniform([2,1])
optimizer = tf.optimizers.SGD()
for i in range (,10) :
with tf.GradientTape() as tape:
y=tf*add(x,x)
gradients = tape. gradient(y,x)
optimizer.apply_gradients([(gradients, x)])
C:
x=tf. Variable(tf.random.uniform([1,2]))
optimizer = tf.optimizers.SGD()
for i in range (,10) :
with tf.GradientTape() as tape:
y=tf*add(tf.(x),x)
gradients = tape. gradient(y,x)
optimizer.apply_gradients([(gradients, x)])
 Which piece of code would apply stochastic gradient descent for 10

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!