def __init__(self, net_type, conf): if net_type == 'drqn': self.agent = DRQNAgent(conf) elif net_type == 'gru': self.agent = GRUAgent(conf) else: self.agent = DQNAgent(conf)
def __init__(self, net_type, conf): if net_type == "drqn": self.agent = DRQNAgent(conf) elif net_type == "dgruqn": self.agent = DGRUQNAgent(conf) else: self.agent = DQNAgent(conf)
class Main(): def __init__(self, net_type, conf): self.agent = DQNAgent(conf) #Se encarga de realizar todo el proceso de entrenamiento del agente def train(self, steps): self.agent.train(steps) #Se encarga de jugar un episodio con lo aprendido por la red neuronal especificiada. def play(self, steps, net_path): self.agent.play(steps, net_path)
class Main(): def __init__(self, net_type, conf): if net_type == "drqn": self.agent = DRQNAgent(conf) else: self.agent = DQNAgent(conf) def train(self, steps): self.agent.train(steps) def play(self, episodes, net_path): self.agent.play(episodes, net_path)
def __init__(self, network_type, conf): if network_type == 'dqn': print('DQN') self.agent = DQNAgent(conf) elif network_type == 'drqn': print('LSTM-DRQN') self.agent = DRQNAgent(conf) elif network_type == 'goru': print('GORU-DRQN') self.agent = GORUAgent(conf) elif network_type == 'eunn': print('EUNN-DRQN') self.agent = EUNNAgent(conf) else: raise ValueError('Incompatible network type ' + network_type)
def __init__(self, net_type, conf): self.agent = DQNAgent(conf)
EPS_DECAY = 0.995 EPS_MIN = 0.01 def get_env_path(): if len(sys.argv) != 2: print("ERROR: invalid arguments list") print("Usage: train.py <path_to_unity_env>") sys.exit(1) return sys.argv[1] if __name__ == '__main__': env = BananaEnv(get_env_path()) agent = DQNAgent( env, DQNConfig( buffer_size=BUFFER_SIZE, batch_size=BATCH_SIZE, learning_rate=LEARNING_RATE, tau=TAU, gamma=GAMMA, fc1_units=FC1_UNITS, fc2_units=FC2_UNITS, episode_max_length=EPISODE_MAX_LENGTH, )) agent.train(N_STEPS, UPDATE_EVERY, PRINT_EVERY, EPS_INIT, EPS_DECAY, EPS_MIN) input('Press key to continue...') env.close()
import sys from src.banana_env import BananaEnv from src.dqn_agent import DQNAgent, DQNConfig from src.random_agent import RandomAgent # choose agent: dqn | random AGENT = "dqn" def get_env_path(): if len(sys.argv) != 2: print("ERROR: invalid arguments list") print("Usage: rollout.py <path_to_unity_env>") sys.exit(1) return sys.argv[1] if __name__ == "__main__": env = BananaEnv(get_env_path()) agent = RandomAgent(env) if AGENT == "random" else DQNAgent( env, DQNConfig()) agent.restore("model.pt") agent.run_episode() env.close()