这是我想将2个张量(张量,array_tensor)连接成“ new_tensor”的代码,但是我返回了此错误。
如果它可以帮助我在gpu的Tensorflow 1.14.1-dev20190318上运行
tensor = None
array_tensor = None
dummy_tensor = tf.convert_to_tensor(0.0,dtype=tf.float32)
dummy_tensor_2 = tf.convert_to_tensor(0.0,dtype=tf.float32)
dataset = tf.data.Dataset.from_tensors(tensors=(dummy_tensor,dummy_tensor_2))
for row in float_validation:
print(row[0])
tensor = tf.convert_to_tensor(row[0], dtype=tf.float32)
array_tensor = tf.convert_to_tensor(row[1],dtype=tf.float32)
new_tensor = tf.concat([tensor,array_tensor],axis=2)
# dataset = dataset.concatenate(tf.data.Dataset.from_tensors(tensors=(tensor,array_tensor)))
dataset = dataset.concatenate(tf.data.Dataset.from_tensors(tensors=(new_tensor)))
File "D:\School\Last_Year\thesis_actual\thesis\thesis_prototype\test.py", line 126, in <module>
new_tensor = tf.concat([tensor,array_tensor],axis=2)
File "D:\School\Last_Year\thesis_actual\thesis\thesis_prototype\venv\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "D:\School\Last_Year\thesis_actual\thesis\thesis_prototype\venv\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1271, in concat
return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
File "D:\School\Last_Year\thesis_actual\thesis\thesis_prototype\venv\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1378, in concat_v2
_six.raise_from(_core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: ConcatOp : Expected concatenating dimensions in the range [0, 0), but got 2 [Op:ConcatV2] name: concat```