Ejemplo n.º 1
0
def runApeX():
    config = read_config("./Configs/configApeX.yml")
    epsilons = config["min_epsilons"]
    N_ACTORS = config['n_actors']

    BaseManager.register('ReplayBM', Memory)
    BaseManager.register('LearnerBM', Learner)
    BaseManager.register('ServerBM', Server)
    manager = BaseManager()
    manager.start()
    server = manager.ServerBM()
    replay = manager.ReplayBM(config)

    learner = manager.LearnerBM(config)

    processes = [
        Process(target=run,
                args=(replay, learner, server, config, epsilons[p], p))
        for p in range(N_ACTORS)
    ]

    p_learner = Process(target=learner.train_nn, args=(
        replay,
        server,
    ))

    p_learner.start()
    for p in processes:
        p.start()

    p_learner.join()
    for p in processes:
        p.join()
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from collections import deque
import random
import time
import sys

from Models.Networks.SimpleNetwork import Network

from utils.tool import read_config, read_seed
np.random.seed(read_seed())

config = read_config("./Configs/configD2QN.yml")

N_ACTIONS = config["n_actions"]
GAMMA = config["gamma"]
EPSILON_DECAY = config["epsilon_decay"]
EPSILON_MIN = config["epsilon_min"]
BATCH_SIZE = config["batch_size"]
MIN_REPLAY_SIZE = config["min_replay_size"]
TARGET_UPDATE = config["target_update"]
SAMPLING_TIME = config["sampling_time"]

NAME = config["model_name"]


# Deep Q Network agent
class Agent:
    def __init__(self):
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from collections import deque
import random
import time
import sys

from Models.Networks.NoisyDuelingNetwork import Network

from utils.tool import read_config, read_seed
np.random.seed(read_seed())

config = read_config("./Configs/configNoisy.yml")

N_ACTIONS = config["n_actions"]
GAMMA = config["gamma"]
EPSILON_DECAY = config["epsilon_decay"]
EPSILON_MIN = config["epsilon_min"]
BATCH_SIZE = config["batch_size"]
MIN_REPLAY_SIZE = config["min_replay_size"]
TARGET_UPDATE = config["target_update"]
SAMPLING_TIME = config["sampling_time"]

NAME = config["model_name"]
# Deep Q Network agent
class Agent:
	def __init__(self):

		#Initialisationn of environnment variables
from Models.DistributedModels.Apex.Main import runApeX
from utils.tool import read_config, read_seed, write_seed

if __name__ == "__main__":

	parser = argparse.ArgumentParser(
			description='choose your model')
	parser.add_argument('-model', type=str, default='DQN', help='DQN/D2QN/D3QN/Noisy/PER/ApeX')
	parser.add_argument('-seed', type=int, default=-1, help='save/init')
	

	args = parser.parse_args()

	#seeds
	if args.seed == -1:
		config = read_config("./Configs/config" + args.model + ".yml")
		write_seed(config["seed"])
	else:
		write_seed(args.seed)
	print("seed:", read_seed())

	#Models
	if args.model == "ApeX":
		runApeX()
	elif args.model == "DQN":
		env = EnvCarla.CarEnv(0)
		agent = ModelDQN.Agent()
		TrainModel.run(config, agent, env)
			
	elif args.model == "D2QN":
		env = EnvCarla.CarEnv(0)
Ejemplo n.º 5
0
                  (sys.version_info.major, sys.version_info.minor,
                   'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
    pass
import carla

import random
import time
import numpy as np
import cv2
import math

from utils.tool import read_config, rgb_to_gray
import pathlib

config = read_config("./Configs/confEnvironmentTest.yml")

SECONDS_PER_EPISODE = config['TIME_WP']
#Image's size
IMG_WIDTH = config['IMG_WIDTH']
IMG_HEIGHT = config['IMG_HEIGHT']

SHOW_CAM = config['SHOW_PREVIEW']

#Distance between two waypoints
NAV_I = config['NAV_I']
START_POSITION = config['position']
TRAJECTORY = config['trajectory']

#Norme
VMAX = config['VMAX']
Ejemplo n.º 6
0
import torch
import numpy as np
import time
import random, sys
from Models.Networks.NoisyDuelingNetwork import Network
import Environments.Environment as EnvCarla
from torch.utils.tensorboard import SummaryWriter

from utils.tool import read_config, read_seed

config = read_config("./Configs/configApeX.yml")
N_ACTIONS = config["n_actions"]
EPSILON_DECAY = config["epsilon_decay"]
UPDATE_REPLAY = config['update_replay']
UPDATE_NETWORK_TIME = config['update_network']



np.random.seed(read_seed())

class Actor:
	def __init__ (self, config, num, epsilon_min):
		#Define env
		self.epsilon = config['epsilon']

		self.epsilon_min = epsilon_min

		self.local_replay = []

		self.num = num
Ejemplo n.º 7
0
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from collections import deque
import random
import time
import sys

from Models.Networks.NoisyDuelingNetwork import Network
from Models.NoDistributedModels import ReplayBuffer

from utils.tool import read_config, read_seed
np.random.seed(read_seed())

config = read_config("./Configs/configPER.yml")

N_ACTIONS = config["n_actions"]
GAMMA = config["gamma"]
EPSILON_DECAY = config["epsilon_decay"]
EPSILON_MIN = config["epsilon_min"]
BATCH_SIZE = config["batch_size"]
MIN_REPLAY_SIZE = config["min_replay_size"]
TARGET_UPDATE = config["target_update"]
SAMPLING_TIME = config["sampling_time"]

NAME = config["model_name"]


# Double Deep Q Network agent
class Agent: