02_tfrecord_example.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:tf_oreilly 作者: chiphuyen 项目源码 文件源码
def write_to_tfrecord(label, shape, binary_image, tfrecord_file):
    """ This example is to write a sample to TFRecord file. If you want to write
    more samples, just use a loop.
    """
    writer = tf.python_io.TFRecordWriter(tfrecord_file)
    # write label, shape, and image content to the TFRecord file
    example = tf.train.Example(features=tf.train.Features(feature={
                'label': _int64_feature(label),
                'shape': _bytes_feature(shape),
                'image': _bytes_feature(binary_image)
                }))
    writer.write(example.SerializeToString())
    writer.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号