Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 比较张量元张量流_Python_Tensorflow - Fatal编程技术网

Python 比较张量元张量流

Python 比较张量元张量流,python,tensorflow,Python,Tensorflow,如果我有x=[0,10],并且我想做如下事情,那么TF中的等效操作是什么 assert x[1] > x[0] 我尝试了以下方法: tf.debugging.assert_greater(x[1], x[0], message=f"{x[1]} has to be greater than {x[0]}" ) 当我有x=tf.constant([10,0])时,它没有抛出任何错误。 谢谢 您没有正确理解tf.debug.assert\

如果我有x=[0,10],并且我想做如下事情,那么TF中的等效操作是什么

assert x[1] > x[0]
我尝试了以下方法:

    tf.debugging.assert_greater(x[1], x[0],
        message=f"{x[1]} has to be greater than {x[0]}"
    )
当我有
x=tf.constant([10,0])时,它没有抛出任何错误。

谢谢

您没有正确理解
tf.debug.assert\u morer
。看看下面的例子。如果
a>b
,它将什么也不做,但是如果
a
,它将抛出一个错误,因此它会反过来

import numpy as np
import tensorflow as tf

tf.debugging.assert_greater(0, 1,message=f"{x[1]} has to be greater than {x[0]}")

----
InvalidArgumentError: 0 has to be greater than 10
Condition x > y did not hold.
First 1 elements of x:
[0]
First 1 elements of y:
[1]


这回答了你的问题吗?我不这么认为。我需要比较一个张量中的元素,而不是比较两个张量
import numpy as np
import tensorflow as tf

tf.debugging.assert_greater(1, 0,message=f"{x[1]} has to be greater than {x[0]}")

----
nothing