Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)])
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions