a = tf.constant([[1,2,3],[4,5,6]])
b = tf.constant([True, False], dtype=tf.bool)
a.eval()
array([[1, 2, 3],
[4, 5, 6]], dtype=int32)
b.eval()
array([ True, False], dtype=bool)
我想对上面的输入应用一个函数,a
, and b
using tf.map_fn
。它将同时输入[1,2,3]
, and True
并输出相似的值。
假设函数只是恒等式:lambda(x,y): x,y
所以,给定输入[1,2,3], True
,它将输出那些相同的张量。
我知道如何使用tf.map_fn(...)
与一个变量,但不是与两个变量。在本例中,我有混合数据类型(int32 和 bool),因此我不能简单地连接张量并在调用后拆分它们。
我可以用吗tf.map_fn(...)
具有不同数据类型的多个输入/输出?