gpt4 book ai didi

python-3.x - 如何在 Tensorflow 2.0 中使用 tf.python_io.TFRecordWriter

转载 作者:行者123 更新时间:2023-12-04 02:48:31 24 4
gpt4 key购买 nike

我想将 .csv 文件转换为 TF 记录。我现在的问题是,python_io 在 Tensorflow 2.0 中不存在。

     writer=tf.python_io.TFRecordWriter(FLAGS.output_path)
path = os.path.join(FLAGS.image_dir)
examples = pd.read_csv(FLAGS.csv_input)
grouped = split(examples, 'filename')
for group in grouped:
tf_example = create_tf_example(group, path)
writer.write(tf_example.SerializeToString())
writer.close()
output_path = os.path.join(os.getcwd(), FLAGS.output_path)
I get this error:
File "generate_tfrecord.py", line 102, in <module>
main()
File "generate_tfrecord.py", line 89, in main
writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
AttributeError: module 'tensorflow' has no attribute 'python_io'

我必须改用什么?

最佳答案

据官方documentationpython.io 包已移至名为 io 的新包。只需交换它们即可。

writer = tf.io.TFRecordWriter(FLAGS.output_path)
# ...

关于python-3.x - 如何在 Tensorflow 2.0 中使用 tf.python_io.TFRecordWriter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56176167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com