问题描述
我有一个名为 train00.tfrecord
的文件,我想通过 tensorflow 读取它。所以我写了下面的代码。
frame_lvl_record = "frame-sample/frame/train00.tfrecord"
for example in tf.io.tf_record_iterator(frame_lvl_record):
print(example)
但它返回了以下错误。
AttributeError Traceback (most recent call last)
/tmp/ipykernel_20529/2760031393.py in <module>
----> 1 for example in tf.io.tf_record_iterator(frame_lvl_record):
2 print(example)
AttributeError: module 'tensorflow._api.v2.io' has no attribute 'tf_record_iterator'
我该如何解决这个依赖问题?
解决方法
'''使用这个命令读取TFRecordDataset
data=tf.data.TFRecordDataset("filenames")
n=10
for raw_record in data.take(n):
print(repr(raw_record))
'''