示例#1
0
def pytest_runtest_call(item):
    # seed = int(item.config.getoption('--pnl-seed'))
    seed = 0
    random.seed(seed)
    np.random.seed(seed)
    from psyneulink.core.globals.utilities import set_global_seed
    set_global_seed(seed)
示例#2
0
def pytest_runtest_call(item):
    # seed = int(item.config.getoption('--pnl-seed'))
    seed = 0
    np.random.seed(seed)
    set_global_seed(seed)

    if 'pytorch' in item.keywords:
        assert pytorch_available
        torch.manual_seed(seed)
示例#3
0
    def __init__(self):

        self.seed = int.from_bytes(os.urandom(4), byteorder="big")

        from psyneulink.core.globals.utilities import set_global_seed
        set_global_seed(self.seed)
        np.random.seed(self.seed+1)

        # Setup a Gym Forager environment for the game
        self.gym_forager_env = ForagerEnv(obs_type='egocentric', incl_values=False, frameskip=2)
        self.gym_forager_env.seed(self.seed+2)

        # Setup an instance of the double DQN agent for determining optimal actions
        self.ddqn_agent = DoubleDQNAgent(model_load_path=MODEL_PATH,
                                         eval_mode=True,
                                         save_frames=False,
                                         render=RENDER,
                                         env=self.gym_forager_env)

        # Setup the PsyNeuLink composition
        self._setup_composition()
示例#4
0
from psyneulink import *
from double_dqn import DoubleDQNAgent

from gym_forager.envs.forager_env import ForagerEnv

parser = argparse.ArgumentParser()
parser.add_argument("--seed", type=int,
        default=int.from_bytes(os.urandom(4), byteorder="big"),
        help='Random seed, seed from os.urandom if unspecified.')
#args = parser.parse_args()

SEED = int.from_bytes(os.urandom(4), byteorder="big")

from psyneulink.core.globals.utilities import set_global_seed
set_global_seed(SEED)
np.random.seed(SEED+1)

# *********************************************************************************************************************
# *********************************************** CONSTANTS ***********************************************************
# *********************************************************************************************************************

# Runtime switches:
MPI_IMPLEMENTATION = True
RENDER = False
PNL_COMPILE = False
RUN = True
SHOW_GRAPH = False
MODEL_PATH = '../../../../double-dqn/models/trained_models/policy_net_trained_0.99_20190214-1651.pt'

# Switch for determining actual action taken in each step