syna.algo.dqn module
DQN agent implementation for discrete action spaces.
Contains:
- QNet: simple 3-layer MLP producing Q-values for each action.
- DQNAgent: lightweight DQN with replay buffer, target network and Adam optimizer.
-
class syna.algo.dqn.DQNAgent(action_size: int = 2, gamma: float = 0.98, lr: float = 0.0005, epsilon: float = 0.1, buffer_size: int = 10000, batch_size: int = 32)[source]
Bases: object
Simplified DQN agent.
The agent uses an epsilon-greedy policy, a replay buffer, and a target network.
-
select_action(state: ndarray) → int[source]
Return an action using epsilon-greedy policy.
-
sync_qnet()[source]
Copy current Q network weights to the target network.
-
update(state, action, reward, next_state, done)[source]
Store transition and update Q network from a sampled batch when available.
-
class syna.algo.dqn.QNet(action_size: int)[source]
Bases: Model
Small feed-forward network that outputs Q-values for each action.
- Args:
action_size: number of discrete actions.
-
forward(x)[source]
Compute the forward pass. Must be implemented by subclasses.