import tensorflow as tf w = tf.Variable(3.0) b = tf.Variable(1.0) x = tf.constant(2.0) yTrue = tf.constant(4.0) with tf.GradientTape() as tape: x1 = x*w x2 = x1 + b lossVal = abs(yTrue-x2) gradientes = tape.gradient(lossVal, [w, b]) print(gradientes[0].numpy()) print(gradientes[1].numpy())
¿No eres miembro todavía? Regístrate ahora
¿Es usted miembro? Login now