building-agents/test.py

42 lines
928 B
Python
Raw Normal View History

2024-06-18 10:49:43 +08:00
# from joblib import load
#
# model = load('AgentPPO/reward_data.pkl')
#
# data = model['mean_episode_reward']
# print(data)
# import torch
#
# model_path = 'AgentDDPG/actor.pth'
#
# checkpoint = torch.load(model_path, map_location=torch.device('cuda'))
#
# # 如果.pth文件保存的是整个模型包含模型结构和参数
# model = checkpoint # 这里假设checkpoint直接就是模型实例有时候可能需要model.load_state_dict(checkpoint['state_dict'])
# 如果.pth文件仅保存了state_dict模型参数
# model = YourModelClass() # 实例化你的模型
# model.load_state_dict(checkpoint)
2024-06-24 11:54:21 +08:00
# print(model)
2024-06-18 10:49:43 +08:00
2024-06-24 11:08:34 +08:00
import pickle
a = 'DDPG'
b = 'PPO'
c = 'SAC'
d = 'TD3'
a1 = '/reward_data.pkl'
a2 = '/loss_data.pkl'
a3 = '/test_data.pkl'
2024-06-18 10:49:43 +08:00
2024-06-24 11:08:34 +08:00
filename = './Agent' + a + a3
2024-06-18 10:49:43 +08:00
2024-06-24 11:08:34 +08:00
# 使用 'rb' 模式打开文件,读取二进制数据
with open(filename, 'rb') as f:
data = pickle.load(f)
2024-06-18 10:49:43 +08:00
2024-06-24 11:08:34 +08:00
print(data)