building-agents/test.py

42 lines
926 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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)
print(model)
import pickle
a = 'DDPG'
b = 'PPO'
c = 'SAC'
d = 'TD3'
a1 = '/reward_data.pkl'
a2 = '/loss_data.pkl'
a3 = '/test_data.pkl'
filename = './Agent' + a + a3
# 使用 'rb' 模式打开文件,读取二进制数据
with open(filename, 'rb') as f:
data = pickle.load(f)
print(data)