ValueError: Can't convert non-rectangular Python sequence to Tensor

前端 未结 2 839
轻奢々
轻奢々 2021-01-17 12:13

I want to change list to tensor with tf.convert_to_tensor, data is following:

data=[

array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,         


        
2条回答
  •  清酒与你
    2021-01-17 13:16

    I'm not sure whether they exist in TensorFlow 1 but TensorFlow 2.0 supports RaggedTensors, which the documentation describes as "... the TensorFlow equivalent of nested variable-length lists."

    I think it would be trivial to convert your data to RaggedTensors. It might even be as easy as:

    data_tensor = tf.ragged.constant(data)
    

提交回复
热议问题