You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.3 KiB

import pickle
import numpy as np
# 查看保存的数据结构:
def inspect_data(pkl_file):
"""检查并显示pickle文件中的数据结构"""
with open(pkl_file, 'rb') as f:
data = pickle.load(f)
print("数据结构概览:")
print("=" * 50)
# 遍历所有键值对
for key, value in data.items():
print(f"\n键名: {key}")
print("-" * 30)
if isinstance(value, np.ndarray):
print(f"类型: numpy.ndarray")
print(f"形状: {value.shape}")
print(f"数据类型: {value.dtype}")
if value.size > 0:
if value.dtype == object:
print("第一个元素形状:", value[0].shape if hasattr(value[0], 'shape') else len(value[0]))
else:
print("数值范围:", f"[{value.min()}, {value.max()}]")
print("样本:")
if value.dtype == object:
print(value[0][:3] if value.size > 0 else "")
else:
print(value[:3] if value.size > 0 else "")
else:
print(f"类型: {type(value)}")
print(f"值: {value}")
if __name__ == "__main__":
pkl_file = "./bathtub_0011.pkl" # 替换为你的文件路径
inspect_data(pkl_file)