我正在使用急切模式。致电Halley,但收到错误消息。此外,还有“条件”和“身体”功能(未显示)。
import tensorflow as tf
import numpy as n
print(tf.__version__)
tf.enable_eager_execution()
def Halley(coeff, x0):
loop_vars=x0[0],coeff
# Add an Op to initialize global variables.
init_op = tf.global_variables_initializer()
result = tf.while_loop(condition, body, loop_vars)
return result
roots = Halley(tf.constant([
[1,-5,6,-4,1],
[1]
]))
File "<ipython-input-5-dab6d9ec95bd>", line 40
roots = Halley(tf.constant([
^
SyntaxError: invalid syntax