コード例 #1
0
ファイル: _ec_throttled_maps.py プロジェクト: annikc/MEMRL
sys.path.append('../../modules/')
from modules.Agents.RepresentationLearning.learned_representations import load_saved_latents
from modules.Agents.EpisodicMemory import EpisodicMemory as Memory
from Analysis.analysis_utils import get_avg_std, get_id_dict, get_grids, plot_each
from modules.Utils import running_mean as rm
from modules.Utils import softmax
from scipy.stats import entropy

data_dir = '../../Data/'
df = pd.read_csv(data_dir + 'ec_throttled_latents_emptyhead.csv')
ref = pd.read_csv(data_dir + 'ec_empty_test.csv')

envs = df.env_name.unique()
size = df.EC_cache_limit.unique()
print('#####', )
ref_dict = get_id_dict(ref, reps=['conv_latents'])

cache_limits = {
    'gridworld:gridworld-v11': {
        1: 400,
        0.75: 300,
        0.5: 200,
        0.25: 100
    },
    'gridworld:gridworld-v31': {
        1: 365,
        0.75: 273,
        0.5: 182,
        0.25: 91
    },
    'gridworld:gridworld-v41': {
コード例 #2
0
import pandas as pd

sys.path.append('../../modules/')
from Analysis.analysis_utils import get_avg_std, get_id_dict, get_grids
from Utils import running_mean as rm

data_dir = '../../Data/results/'
df = pd.read_csv('../../Data/conv_mf_training.csv')
#df = pd.read_csv('../../Data/head_only_retrain.csv')
envs = df.env_name.unique()
reps = df.representation.unique()
print(reps)
envs = np.delete(envs, np.where(envs == 'gridworld:gridworld-v2'))
print('#####', envs)

master_dict = get_id_dict(df)

grids = get_grids([1, 3, 4, 5])

labels_for_plot = {
    'conv': 'Partially Observable State',
    'reward_conv': 'Fully Observable State'
}


def plot_all(save=True, cutoff=25000):
    fig, axs = plt.subplots(4, 2, sharex='col')
    for i in range(len(grids)):
        rect = plt.Rectangle((5, 5), 1, 1, color='g', alpha=0.3)
        axs[i, 0].pcolor(grids[i],
                         cmap='bone_r',
コード例 #3
0
from Analysis.analysis_utils import get_avg_std, get_id_dict, get_grids, plot_each
from modules.Utils import running_mean as rm

data_dir = '../../Data/'
dfa = pd.read_csv(data_dir + 'ec_latent_test.csv')
df = pd.read_csv(data_dir + 'ec_empty_test.csv')
comparison_dat1 = pd.read_csv(data_dir + 'conv_head_only_retrain.csv')
comparison_dat2 = pd.read_csv(data_dir + 'empty_head_only_retrain.csv')
#df = pd.concat([dfa,dfb])
print(df)
envs = df.env_name.unique()
reps = df.representation.unique()
envs = np.delete(envs, np.where(envs == 'gridworld:gridworld-v2'))
print('#####', envs)

master_dict = get_id_dict(df)
slave_dict1 = get_id_dict(comparison_dat1)
slave_dict2 = get_id_dict(comparison_dat2)
print([x[-2:] for x in envs])
grids = get_grids([x[-2:] for x in envs])

#labels_for_plot = {'conv_saved_latents':'Partially Observable State', 'rwd_conv_saved_latents':'Fully Observable State'}
labels_for_plot = {
    'conv_latents': 'Partially Observable State',
    'rwd_conv_latents': 'Fully Observable State'
}
convert_conv_head_to_ec_labels = {
    'conv_latents': 'conv_saved_latents',
    'rwd_conv_latents': 'rwd_conv_saved_latents'
}
コード例 #4
0
sys.path.append('../../modules/')
from Analysis.analysis_utils import get_avg_std, get_id_dict, get_grids, plot_each
from Utils import running_mean as rm

data_dir = '../../Data/'
df = pd.read_csv(data_dir+'ec_testing.csv')
print(df)
envs = df.env_name.unique()
reps = df.representation.unique()
envs = np.delete(envs, np.where(envs == 'gridworld:gridworld-v1'))
reps = np.delete(reps, np.where(reps == 'saved_latents'))
print('#####',reps)
ref = pd.read_csv(data_dir+'ec_empty_test.csv')

ref_dict = get_id_dict(ref,reps=['conv_latents'])
for key in ref_dict.keys():
    print('ref dict', key, ref_dict[key].keys())


master_dict = get_id_dict(df, reps=reps)

print([x[-2:] for x in envs])
grids = get_grids([x[-2:] for x in envs])

convert_rep_to_color = {'analytic successor':'C0', 'onehot':'C1', 'random':'C2','place_cell':'C3'}
labels_for_plot = {'analytic successor':'SR', 'onehot':'onehot', 'random':'random','place_cell':'PC'}

def plot_all(save=False, cutoff=25000, smoothing=5000):
    fig, axs = plt.subplots(4, 3, sharex='col', sharey='col')
    for i in range(len(grids)):
コード例 #5
0
import numpy as np
import matplotlib.pyplot as plt
import pickle
import sys
import gym
import pandas as pd

sys.path.append('../../modules/')
from Utils import running_mean as rm
from Analysis.analysis_utils import get_avg_std, get_id_dict

data_dir = '../../Data/results/'
df2 = pd.read_csv('../../Data/ec_testing.csv')
ids2 = get_id_dict(df2)

env_names = [
    'gridworld:gridworld-v1', 'gridworld:gridworld-v4',
    'gridworld:gridworld-v3', 'gridworld:gridworld-v5'
]
test_env_names = [
    'gridworld:gridworld-v11', 'gridworld:gridworld-v41',
    'gridworld:gridworld-v31', 'gridworld:gridworld-v51'
]

fig, ax = plt.subplots(4, 1)
env_number = 1
print(ids2[test_env_names[env_number]])
list_of_representations = ['saved_latents']
for ind, rep_str in enumerate(list_of_representations):
    print(rep_str)
    av, sd = get_avg_std(ids2[test_env_names[env_number]][rep_str],
コード例 #6
0
ファイル: head_ac_learning.py プロジェクト: annikc/MEMRL
import numpy as np
import matplotlib.pyplot as plt
import pickle
import sys
import gym
import pandas as pd

sys.path.append('../../modules/')
from modules.Utils import running_mean as rm
from Analysis.analysis_utils import get_avg_std, get_id_dict

data_dir = '../../Data/results/'
df1 = pd.read_csv('../../Data/flat_ac_training.csv')
df2 = pd.read_csv('../../Data/ec_testing.csv')

ids1 = get_id_dict(df1)
ids2 = get_id_dict(df2)

env_names = [
    'gridworld:gridworld-v1', 'gridworld:gridworld-v4',
    'gridworld:gridworld-v3', 'gridworld:gridworld-v5'
]
test_env_names = [
    'gridworld:gridworld-v11', 'gridworld:gridworld-v41',
    'gridworld:gridworld-v31', 'gridworld:gridworld-v51'
]
'''
grids = []
for ind, environment_to_plot in enumerate(env_names):
    env = gym.make(environment_to_plot)
    plt.close()