1
我很確定我錯過了一些明顯的東西,但是否不可能在張量流中加入一維張量張量?該string_join
操作只需要張量的列表,我無法找到一個方法來張量轉換到一個列表:如何加入張量流中的張量張量?
>>> x = tf.string_join(['a', 'b'], '')
>>> sess.run(x)
b'ab'
>>> x = tf.string_join(tf.constant(['a', 'b']), '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/digitalroots/anaconda2/envs/dl/lib/python3.6/site-packages/tensorflow/python/ops/gen_string_ops.py", line 164, in string_join
separator=separator, name=name)
File "/home/digitalroots/anaconda2/envs/dl/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 406, in apply_op
(input_name, op_type_name, values))
TypeError: Expected list for 'inputs' argument to 'StringJoin' Op, not Tensor("Const:0", shape=(2,), dtype=string).
這工作只要'value'不是一個佔位符,但如果是,你需要使用'tf.shape(價值)[0]'這是一個dtype int的張量,但不是'int32',所以不能與'tf.split()'一起使用。 – src