在TF2.X使用gradients碰到此问题在代码tf.compat.v1.disable_eager_execution() TF2.x在使用梯度函数会出现超时错误, 在代码前添加上述代码即可以解决问题