How to use Dataset API to read TFRecords file of lists of variant length?

后端 未结 2 938
离开以前
离开以前 2020-12-28 11:46

I want to use Tensorflow\'s Dataset API to read TFRecords file of lists of variant length. Here is my code.

def _int64_feature(value):
    # value must be          


        
2条回答
  •  天涯浪人
    2020-12-28 12:35

    The error is very simple. Your data is not FixedLenFeature it is VarLenFeature. Replace your line:

     'data':tf.FixedLenFeature([], tf.int64)}
    

    with

     'data':tf.VarLenFeature(tf.int64)}
    

    Also, when you call print(i.eval()) and print(data.eval()) you are calling the iterator twice. The first print will print 0, but the second one will print the value of the second row [ 0, 50, 89, 147, 196]. You can do print(sess.run([i, data])) to get i and data from the same row.

提交回复
热议问题