def __init__(self): self.n_games = 0 self.epsilon = 0 #reandonmess self.gamma = 0.9 #discount rate self.model = Linear_Qnet(11, 256, 3) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma) self.memory = deque(maxlen=MAX_MEMEORY)
def __init__(self): self.number_of_games = 0 self.epsilon = 0 # randomness self.gamma = 0.8 # discount rate self.memory = deque(maxlen=MAX_MEMORY) self.model = LinearQNet(11, 256, 3) self.trainer = QTrainer(self.model, learning_rate=LR, gamma=self.gamma)
def __init__(self): self.num_games = 0 self.epsilon = 0 # to control the randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen=MAX_MEMORY) # pop left self.model = Linear_QNet(11, 256, 3) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma)
def __init__(self): self.n_games = 0 self.epsilon = 0 # randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen=MAX_MEMORY) # popleft() self.model = Linear_QNet(4, 256, 4) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma)
def __init__(self): self.memory = deque(maxlen=MAX_MEM) self.n_games: int = 0 self.epsilon = 0 self.gamma = 0.9 self.model = Q_Net(11, 256, 3) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma)
def __init__(self): self.epsilion = 0.999 self.gamma = 0.9 self.memory = deque(maxlen=MAX_MEMORY) self.model = Linear_QNet(2, 256, 4) self.trainer = QTrainer(self.model, LR, self.gamma) self.epsilion_decay_value = 0.998
def __init__(self): self.n_games = 0 self.epsilon = 0 #randomness self.gamma = 0.9 #discount rate self.memory = deque(maxlen=MAX_MEMORY) #popleft() self.model = Linear_QNet(11, 256, 3) #input_lauer=11,hidden:256 ,output:3 self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma)
def __init__(self, agent_cfg) -> None: self.n_games = 0 self.agent_cfg = agent_cfg self.epsilon = agent_cfg.epsilon # randomness self.random_until = agent_cfg.random_until self.memory = deque(maxlen=agent_cfg.max_memory_size) self.model = LinearQNet(agent_cfg.model) self.trainer = QTrainer(self.model, agent_cfg.lr, agent_cfg.gamma)
def __init__(self): self.n_games = 0 self.epsilon = 0.5 # randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen=MAX_MEMORY) # popleft() self.model = Linear_QNet(2, 256, 4) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma) self.epsilon_decay_value = (self.epsilon) / (END_EPSILON_DECAYING - START_EPSILON_DECAYING)
def __init__(self): with open('games.txt', 'r') as f: self.n_games = int(f.read()) print(self.n_games) self.epsilon = 0 self.gamma = 0.9 self.memory = deque(maxlen=MAX_MEMORY) self.model = Linear_QNet(11, 256, 3) #self.model.load_state_dict(torch.load('model/model.pth')) self.model.eval() self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma)
def __init__(self, use_checkpoint=False): self.no_of_games = 0 self.epsilon = 0 # randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen=MAX_MEMORY) self.model = Linear_QNet(11, 256, 3) self.trainer = QTrainer(self.model, lr=LR, gamma=self.gamma) if use_checkpoint: checkpoint = torch.load("./model/model.pth") self.model.load_state_dict(checkpoint) self.model.eval()
def __init__(self): self.n_games = 0 self.epsilon = 0 # randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen = max_memory) self.model = Linear_QNet(11, 256, 3) PATH = './model/model.pth' if os.path.exists(PATH): self.model.load_state_dict(torch.load(PATH)) # self.model.eval() print('Pretrained = True') self.trainer = QTrainer(self.model, lr = lr, gamma = self.gamma)
def __init__(self, args, model): self.parameters_file = args.parameters_file self.args = args self.parameters = yaml.load(open(self.parameters_file, 'r'), Loader=yaml.FullLoader) self.n_games = 0 self.epsilon = 0 # randomness self.gamma = 0.9 # discount rate self.memory = deque(maxlen=self.parameters["max_memory"]) # popleft() self.model = model self.trainer = QTrainer(self.model, lr=self.parameters["lr"], gamma=self.gamma)
def __init__(self): self.n_games = 0 self.n_state = 14 self.frame_to_read = 1 self.epsilon = 0.4 self.gamma = 0.8 self.memory = deque(maxlen=MAX_MEM) self.states = deque(maxlen=self.frame_to_read) for _ in range(self.frame_to_read): self.states.append([0 for _ in range(self.n_state)]) self.trainer = QTrainer(self.n_state * self.frame_to_read, LR, self.n_state * self.frame_to_read, [256, 256], 3, self.gamma)
def __init__(self): self.numberOfGames = 0 self.epsilon = 0 # controlls randomness self.gamma = 0.9 # discount rate, <1 # will popleft if there is too much in memory self.memory = deque(maxlen=maxMemory) self.model = Linear_QNet(11, 256, 3) if os.path.isfile('./model/model.pth'): model_folder_path = './model/model.pth' self.model.load_state_dict(torch.load(model_folder_path)) self.trainer = QTrainer(self.model, lr=learningRate, gamma=self.gamma)
def __init__(self, game, pars=dict()): """ (Agent, Snake, dict()) -> None Initialize everything get everything that is passed from json file to modify attributes and train model """ self.n_games = 0 self.epsilon = pars.get('eps', EPSILON) self.eps = pars.get('eps', EPSILON) self.gamma = pars.get('gamma', GAMMA) # discount rate self.eps_range = pars.get('eps_range', EPS_RANGE) print(self.epsilon, self.eps) self.memory = deque(maxlen=MAX_MEMORY) # popleft() self.model = Linear_QNet(len(game.get_state()), pars.get('hidden_size', HIDDEN_SIZE), OUTPUT_SIZE) self.trainer = QTrainer(self.model, lr=pars.get('lr', LR), gamma=self.gamma) self.game = game