正在尝试使用此代码来生成具有一系列数字的扩展数组,但这在第 d = tf.tile(k, [m])
行中抛出错误
import tensorflow as tf
min_rating = tf.constant(0, tf.int64)
max_rating = tf.constant(12, tf.int64)
m = max_rating - min_rating + 1
k = tf.range(m, dtype=tf.int64)
d = tf.tile(k, [m])
with tf.Session() as sess:
a = sess.run([d])
print a
以下是错误日志:
d = tf.tile(k, [m])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3740, in tile
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 493, in apply_op
raise err
TypeError: List of Tensors when single Tensor expected
我找不到任何参考。tf.range
返回一个张量序列吗?
[m]
第d = tf.tile(k, [m])
行是错误所指的"张量列表"。我猜你用括号括m
来提出tf.tile
一维张量的multiples
论点。结果只是[m]
只是张量列表。您可能希望使用tf.reshape
来制作一维张量,即将错误行更改为:
d = tf.tile(k, tf.reshape(m, [1]))