-->

Sunday, March 4, 2018

Q-learning is a model-free reinforcement learning technique. It is able to compare the expected utility of the available actions (for a given state) without requiring a model of the environment. Additionally, Q-learning can handle problems with stochastic transitions and rewards, without requiring adaptations.

It has been proven that for any finite Markov decision process (MDP), Q-learning eventually finds an optimal policy, in the sense that the expected value of the total reward return over all successive steps, starting from the current state, is the maximum achievable.

Specifically, Q-learning can identify an optimal action-selection policy for any given (finite) MDP. It works by learning an action-value function Q ( s , a ) {\displaystyle Q(s,a)} , which ultimately gives the expected utility of a given action a {\displaystyle a} while in a given state s {\displaystyle s} and following an optimal policy thereafter. A policy π {\displaystyle \pi } , is a rule that the agent follows in selecting actions, given the state it is in. When such an action-value function is learned, the optimal policy can be constructed by selecting the action with the highest value in each state.

Algorithm




Q Learning Explained - Can we train an AI to complete it's objective in a video game world without needing to build a model of the world before hand? The answer is yes using Q learning! I'll go through several use...

The problem space consists of an agent, a set of states S {\displaystyle S} , and a set of actions per state A {\displaystyle A} . By performing an action a ∈ A {\displaystyle a\in A} , the agent can move from state to state. Executing an action in a specific state provides the agent with a reward (a numerical score). The goal of the agent is to maximize its total (future) reward. It does this by learning which action is optimal for each state. The action that is optimal for each state is the action that has the highest long-term reward. This reward is a weighted sum of the expected values of the rewards of all future steps starting from the current state, where the weight for a step from a state Î" t {\displaystyle \Delta t} steps into the future is calculated as γ Î" t {\displaystyle \gamma ^{\Delta t}} . Here, γ {\displaystyle \gamma } is a number between 0 and 1 ( 0 ≤ γ ≤ 1 {\displaystyle 0\leq \gamma \leq 1} ) called the discount factor and trades off the importance of earlier versus later rewards. γ {\displaystyle \gamma } may also be interpreted as the probability to succeed (or survive) at every step Î" t {\displaystyle \Delta t} .

The algorithm, therefore, has a function that calculates the quality of a state-action combination:

Q : S × A â†' R {\displaystyle Q:S\times A\to \mathbb {R} } .

Before learning begins, Q {\displaystyle Q} is initialized to a possibly arbitrary fixed value (chosen by the programmer). Then, at each time t {\displaystyle t} the agent selects an action a t {\displaystyle a_{t}} , observes a reward r t {\displaystyle r_{t}} , enters a new state s t + 1 {\displaystyle s_{t+1}} (that may depend on both the previous state s t {\displaystyle s_{t}} and the selected action), and Q {\displaystyle Q} is updated. The core of the algorithm is a simple value iteration update, using the weighted average of the old value and the new information:

Q ( s t , a t ) ← ( 1 âˆ' α ) â‹… Q ( s t , a t ) ⏟ o l d   v a l u e + α ⏟ l e a r n i n g   r a t e â‹… ( r t ⏟ r e w a r d + γ ⏟ d i s c o u n t   f a c t o r â‹… max a Q ( s t + 1 , a ) ⏟ e s t i m a t e   o f   o p t i m a l   f u t u r e   v a l u e ) ⏞ l e a r n e d   v a l u e {\displaystyle Q(s_{t},a_{t})\leftarrow (1-\alpha )\cdot \underbrace {Q(s_{t},a_{t})} _{\rm {old~value}}+\underbrace {\alpha } _{\rm {learning~rate}}\cdot \overbrace {{\bigg (}\underbrace {r_{t}} _{\rm {reward}}+\underbrace {\gamma } _{\rm {discount~factor}}\cdot \underbrace {\max _{a}Q(s_{t+1},a)} _{\rm {estimate~of~optimal~future~value}}{\bigg )}} ^{\rm {learned~value}}}

where r t {\displaystyle r_{t}} is the reward observed for the current state s t {\displaystyle s_{t}} , and α {\displaystyle \alpha } is the learning rate ( 0 < α ≤ 1 {\displaystyle 0<\alpha \leq 1} ).

An episode of the algorithm ends when state s t + 1 {\displaystyle s_{t+1}} is a final or terminal state. However, Q-learning can also learn in non-episodic tasks. If the discount factor is lower than 1, the action values are finite even if the problem can contain infinite loops.

For all final states s f {\displaystyle s_{f}} , Q ( s f , a ) {\displaystyle Q(s_{f},a)} is never updated, but is set to the reward value r {\displaystyle r} observed for state s f {\displaystyle s_{f}} . In most cases, Q ( s f , a ) {\displaystyle Q(s_{f},a)} can be taken to be equal to zero.

Influence of variables on the algorithm


Ethical Issues in Artificial Reinforcement Learning | Essays on ...
Ethical Issues in Artificial Reinforcement Learning | Essays on .... Source : reducing-suffering.org

Learning rate

The learning rate or step size determines to what extent newly acquired information overrides old information. A factor of 0 makes the agent learn nothing, while a factor of 1 makes the agent consider only the most recent information. In fully deterministic environments, a learning rate of α t = 1 {\displaystyle \alpha _{t}=1} is optimal. When the problem is stochastic, the algorithm converges under some technical conditions on the learning rate that required it to decrease to zero. In practice, often a constant learning rate is used, such as α t = 0.1 {\displaystyle \alpha _{t}=0.1} for all t {\displaystyle t} .

Discount factor

The discount factor γ {\displaystyle \gamma } determines the importance of future rewards. A factor of 0 will make the agent "myopic" (or short-sighted) by only considering current rewards, while a factor approaching 1 will make it strive for a long-term high reward. If the discount factor meets or exceeds 1, the action values may diverge. For γ = 1 {\displaystyle \gamma =1} , without a terminal state, or if the agent never reaches one, all environment histories become infinitely long, and utilities with additive, undiscounted rewards generally become infinite. Even with a discount factor only slightly lower than 1, Q-function learning leads to propagation of errors and instabilities when the value function is approximated with an artificial neural network. In that case, it is known that starting with a lower discount factor and increasing it towards its final value accelerates learning.

Initial conditions (Q0)

Since Q-learning is an iterative algorithm, it implicitly assumes an initial condition before the first update occurs. High initial values, also known as "optimistic initial conditions", can encourage exploration: no matter what action is selected, the update rule will cause it to have lower values than the other alternative, thus increasing their choice probability. The first reward r {\displaystyle r} can be used to reset the initial conditions. According to this idea, the first time an action is taken the reward is used to set the value of Q {\displaystyle Q} . This allows immediate learning in case of fixed deterministic rewards. RIC seems to be consistent with human behaviour in repeated binary choice experiments.

Implementation


Deep Q Learning · Artificial Inteligence
Deep Q Learning · Artificial Inteligence. Source : leonardoaraujosantos.gitbooks.io

Q-learning at its simplest uses tables to store data. This approach falters with increasing sizes of state/action space of the system.

Function approximation

One solution is to use an (adapted) artificial neural network as a function approximator.

More generally, Q-learning can be combined with function approximation. This makes it possible to apply the algorithm to larger problems, even when the state space is continuous. Additionally, it may speed up learning in finite problems, due to the fact that the algorithm can generalize earlier experiences to previously unseen states.

Quantization

Another technique to decrease the state/action space quantizes possible values. Consider the example of learning to balance a stick on a finger. To describe a state at a certain point in time involves the position of the finger in space, its velocity and the angle of the stick. This yields a three-element vector that describes one state, i.e. a snapshot of one state encoded into three values. The problem is that infinitely many possible states are present. To shrink the possible space of valid actions multiple values are assigned to a bucket. The exact distance of the finger from its starting position (-Infinity to Infinity) but rather that it is far away or not (Near, Far).

History


artificial intelligence - Reinforcement learning: Differences ...
artificial intelligence - Reinforcement learning: Differences .... Source : stackoverflow.com

Q-learning was introduced by Watkins in 1989. The convergence proof was presented by Watkins and Dayan in 1992.

Watkins was addressing “Learning from delayed rewards”, the title of his PhD Thesis. Eight years earlier in 1981 the same problem under the name of “Delayed reinforcement learning” was solved by a system named Crossbar Adaptive Array (CAA). It was initially published in 1982. The memory matrix W(a,s) of the presented CAA architecture is the same as the Q-table of Q-learning. The architecture shown in the Figure introduced the term “state evaluation” in reinforcement learning. The crossbar learning algorithm, written in mathematical pseudocode in the paper, in each iteration performs the following computation:

  • In state s perform action a;
  • Receive consequence state s’;
  • Compute state evaluation v(s’);
  • Update crossbar value W’(a,s) = W(a,s) + v(s’).

The term “secondary reinforcement” is borrowed from animal learning theory, to model state values via backpropagation: the state value v(s’) of the consequence situation is backpropagated to the previously encountered situation s. In a crossbar fashion, CAA computes state values vertically and actions horizontally. Demonstration graphs showing delayed reinforcement learning contained states (desirable, undesirable, and neutral states), which were computed by state evaluation function. This learning system in 1997 was recognized as a forerunner of the Q-learning algorithm.

Variants


Accumulation vs. replacement; model- free vs. model-based RL ...
Accumulation vs. replacement; model- free vs. model-based RL .... Source : slideplayer.com

Deep Q-learning

An application of Q-learning to deep learning, by Google DeepMind, titled "deep reinforcement learning" or "deep Q-learning", was successful at playing Atari 2600 games at expert human levels. Preliminary results were presented in 2014. The system used a deep convolutional neural network, which used hierarchical layers of tiled convolutional filters to mimic the effects of receptive fields. Reinforcement learning is unstable or divergent when a nonlinear function approximator such as a neural network is used to represent Q. This instability comes from the correlations present in the sequence of observations, the fact that small updates to Q may significantly change the policy and the data distribution, and the correlations between Q and the target values. This variant of Q-learning, used a biologically inspired mechanism termed experience replay that randomizes over the data, thereby removing correlations in the observation sequence and smoothing over changes in the data distribution. It also used an iterative update that adjusts Q towards target values that are only periodically updated, further reducing correlations with the target.

Double Q-learning

Because the maximum approximated action value is used in Q-learning, in noisy environments Q-learning can sometimes overestimate the action values, slowing the learning. A variant called Double Q-learning was proposed to correct this. This algorithm was later combined with deep learning, as in the DQN algorithm, resulting in Double DQN, which outperforms the original DQN algorithm.

Others

Delayed Q-learning is an alternative implementation of the online Q-learning algorithm, with probably approximately correct (PAC) learning.

Greedy GQ is a variant of Q-learning to use in combination with (linear) function approximation. The advantage of Greedy GQ is that convergence guarantees can be given even when function approximation is used to estimate the action values.

See also


RL at Last! Q- learning and buddies. Administrivia R3 due today ...
RL at Last! Q- learning and buddies. Administrivia R3 due today .... Source : slideplayer.com

  • Reinforcement learning
  • Temporal difference learning
  • SARSA
  • Iterated prisoner's dilemma
  • Game theory

References


Deep Learning-03]DQN for Flappybirld - CSDN博客
Deep Learning-03]DQN for Flappybirld - CSDN博客. Source : blog.csdn.net

External links



  • Watkins, C.J.C.H. (1989). Learning from Delayed Rewards. PhD thesis, Cambridge University, Cambridge, England.
  • Strehl, Li, Wiewiora, Langford, Littman (2006). PAC model-free reinforcement learning
  • Reinforcement Learning: An Introduction by Richard Sutton and Andrew S. Barto, an online textbook. See "6.5 Q-Learning: Off-Policy TD Control".
  • Piqle: a Generic Java Platform for Reinforcement Learning
  • Reinforcement Learning Maze, a demonstration of guiding an ant through a maze using Q-learning.
  • Q-learning work by Gerald Tesauro
  • Q-learning work by Tesauro Citeseer Link
  • Q-learning algorithm implemented in processing.org language
  • Solution for the pole balancing problem with Q(lambda) / SARSA(lambda) and the fourier basis in javascript


 
Sponsored Links