惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
博客园 - 叶小钗
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
N
Netflix TechBlog - Medium
B
Blog
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理

博客园 - 提高效率!

Python多进程处理数据 内网配置深度学习环境 Vscode个人配置喜好记录 用python直接提取gee数据的value(无需下载) 从tiff影像中提取多个点的像素值 WSL下挂载移动硬盘 ubuntu统计当前目录下的文件数量 常见的距离算法和相似度计算方法 常用的坐标系及其EPSG编码 仿 GEE 的平台汇总 stata 学习 matplotlib 颜色速查 解决proplot和Matplotlib版本冲突问题 Matplotlib 设置画布 Landsat 使用QA波段去云 将社会脆弱性纳入高分辨率全球洪水风险绘图 Python绘图代码snippets Micro-Estimates of Wealth for all Low 数据搜集 Latex 符号速查表 Ubuntu 服务器常用命令
python读取tfrecord单个数据
提高效率! · 2025-02-15 · via 博客园 - 提高效率!
import numpy as np
def parse_tfrec(filename):
    # 遍历每条样本
    feature = None
    for raw_record in tf.data.TFRecordDataset(filename):
        example = tf.train.Example()
        example.ParseFromString(raw_record.numpy())
        feature = example.features.feature
        # print(list(feature.keys()))
    return feature

def show_info(feature):
    keys = list(feature.keys())
    for k in keys:
        # print(feature[k])
        if feature[k].HasField('bytes_list'):
            print(k, "bytes_list", feature[k].bytes_list.value)
        if feature[k].HasField('float_list'):
            feature_numpy = np.array(feature[k].float_list.value)
            if len(feature_numpy) == 1:
                print(k, "float_list", feature_numpy)
            else:
                print(k, "float_list",feature_numpy.shape)
        # else:
        #     print(feature[k])
    # print(feature['year'])

feature = parse_tfrec("./samples_split/AO7_2016_2_8.tfrec")
show_info(feature)