1 changed files with 40 additions and 0 deletions
@ -0,0 +1,40 @@ |
|||
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) |
Loading…
Reference in new issue