File size: 989 Bytes
b49af5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import argparse
import pickle
import keras
import numpy as np

STORING_PATH = '../offline_rl_results/'
MODELS_PATH = './trained_models/'

def save_results(environment, approximator, seed, rewards):
    storing_path = os.path.join(STORING_PATH, environment, approximator, str(seed))
    if not os.path.exists(storing_path):
        os.makedirs(storing_path)
    
    np.save(storing_path + '/' + 'upside_down_rewards.npy', rewards)

def save_trained_model(environment, seed, algorithm, model):
    storing_path = os.path.join(MODELS_PATH, environment, str(seed), algorithm)
    if not os.path.exists(storing_path):
        os.makedirs(storing_path)
    
    model.save_weights(storing_path + '/' + 'trained_model.h5')

def save_offline_results(environment, algorithm, seed, returns):
    storing_path = os.path.join(STORING_PATH, algorithm, str(seed))
    if not os.path.exists(storing_path):
        os.makedirs(storing_path)

    np.save(storing_path + '/rewards.npy', returns)