`loss` passed to Optimizer.compute_gradients should be a function when eager execution is enabled. --> optimizer.minimize()
When eager execution is enabled, loss should be a Python function that takes no arguments and computes the value to be minimized.
I am trying to resolve a Linear Regression problem using TensorFlow & I came across this RuntimeError
"loss passed to Optimizer.compute_gradients should be a function when eager execution is enabled."
after execution of 'train = optimizer.minimize(loss)' in the below code :
a = tf.Variable(20.0)
b = tf.Variable(30.2)
y = a * train_x + b
loss = tf.reduce_mean(tf.square(y - train_y))
optimizer = tf.compat.v1.train.GradientDescentOptimizer(0.05)
train = optimizer.minimize(loss)
where train_x, train_y --> a set of array values from a column of data frame