Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
4_Deep Q-Networks and Beyond
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Deep Q-Networks and Beyond"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this code, we apply a DQN(Deep Q-networks) using both DDQN(Double Deep Q-networks) and Dueling DQN to the navigation task in a basic grid world."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import gym\n",
"import numpy as np\n",
"import random\n",
"import tensorflow as tf\n",
"import matplotlib.pyplot as plt\n",
"import scipy.misc\n",
"import os\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load the game environment"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"we can adjust the size of the gridworld. Getting smaller size gives an easier task for DQN, larger increases the challenge."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD8CAYAAABXXhlaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAADOFJREFUeJzt3V2sHPV5x/HvrzaEQIqMeZOLoQckRECVMNSiUKoqhdBSEkEvkgoUVVGFxE3aQhMpMe0FitQLIlUJuagiIUiKKspLHGgsKyK1HKKqNw7mpQlgCIa4cArBJoWSJlJbJ08vdqwcOcecOT67e3b4fz/SandmdzX/2dFvZ3bOnOdJVSGpLb+y2gOQNH0GX2qQwZcaZPClBhl8qUEGX2qQwZcatKLgJ7k6yfNJ9ibZMq5BSZqsHO0FPEnWAN8HrgLmgceAG6rq2fENT9IkrF3Bey8B9lbVSwBJ7geuA44Y/FNOOaXm5uZWsEhJ72Tfvn288cYbWep1Kwn+GcArC6bngd96pzfMzc2xe/fuFSxS0jvZvHlzr9et5Df+Yt8qv/S7IclNSXYn2X3gwIEVLE7SuKwk+PPAmQumNwKvHv6iqrqzqjZX1eZTTz11BYuT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B4FNVdT5wKfCJbvxbgJ1d7cGd3fSQ3AzsWTA95FqKXwQeqar3AxcyWq9Bbp+J17qsqqncgMuAby6YvhW4dVrLn8D6fB24Cnge2NDN2wA8v9pjW8Y6bGQUhiuA7UAYXSCydrFtNss34ETgB3TnrRbMH+T2YVTK7hVgPaP/ot0O/MG4ts80D/UPrcghg63Tl2QOuAjYBZxeVa8BdPenrd7Ilu0O4NPAz7vpkxluLcVzgAPAV7qfLnclOYGBbp+acK3LaQY/i8wb3J8UkrwP+BpwS1W9vdrjOVpJPgzsr6rHF85e5KVD2UZrgYuBL1XVRYwuDR/EYf1iVlrrcinTDP48cOaC6SPW6ZtVSY5hFPp7q+qhbvbrSTZ0z28A9q/W+JbpcuDaJPuA+xkd7t9Bz1qKM2gemK9RxSgYVY26mOFunxXVulzKNIP/GHBud1byWEYnKrZNcfkr0tUbvBvYU1WfX/DUNkY1B2FAtQer6taq2lhVc4y2xbeq6mMMtJZiVf0QeCXJed2sQ7UhB7l9mHStyymfsLgG+D7wIvDXq30CZZlj/x1Gh1XfBZ7qbtcw+l28E3ihu1+/2mM9inX7ALC9e3wO8B1gL/BV4D2rPb5lrMcmYHe3jf4JOGnI2wf4LPAc8DTwD8B7xrV9vHJPapBX7kkNMvhSgwy+1CCDLzXI4EsNMvhSgwy+1CCDLzXo/wEEFwK5xTR0jAAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2b7996dcef0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from gridworld import gameEnv\n",
"\n",
"env = gameEnv(partial=False, size=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Above gridworld is an environment of our agent controls the blue box, a left of right. The goal is to move the blue box to the green area(for +1 reward) and aviod the red area(for -1 reward). each box and area is randomized in every episode."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Implementing the network itself"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*convolution_layer = tf.contrib.layers.convolution2d(input, num_outputs, kernel_size, stride, padding)*\n",
"* *num_outs* : how many filiters we'd like to apply to the previous layer.\n",
"* *kernel_size* : how large a window we'd like to slide over the previous layer.\n",
"* *stribe* : how many pixels we want to skip as we slide the window across the layer.\n",
"* *padding* \n",
" + \"VALID\" : to make our window to slide over just the bottom layer. \n",
" + \"SAME\" : add padding around it "
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"class Qnetwork():\n",
" def __init__(self, h_size):\n",
" # The network recieves a frame from the game, flattened into an array.\n",
" # It then resizes it and processes it through four convolutional layers.\n",
" self.scalarInput = tf.placeholder(shape=[None,21168],dtype=tf.float32)\n",
" self.imageIn = tf.reshape(self.scalarInput,shape=[-1,84,84,3])\n",
" \n",
" # 1st conv makes 8X8 kernels with 4 strides 32 activation map\n",
" # output size : (the size of image - that of filter) / stride +1 \n",
" # Because of \"VALID\" option(zero padding is not exist), = (84 - 8) / 4 + 1 = 20\n",
" # the size of activation volumn : 20X20X32 \n",
" self.conv1 = tf.contrib.layers.convolution2d( \\\n",
" inputs=self.imageIn, num_outputs=32, kernel_size=[8,8],stride=[4,4],padding='VALID', biases_initializer=None)\n",
" \n",
" # likewise, 2nd conv makes 4X4 kernels with 2 strides 64 activation map \n",
" # with \"VALID\" option, (20-4)/2 +1 = 9\n",
" # the size of activation volumn : 9X9X64 \n",
" self.conv2 = tf.contrib.layers.convolution2d( \\\n",
" inputs=self.conv1, num_outputs=64, kernel_size=[4,4],stride=[2,2],padding='VALID', biases_initializer=None)\n",
" \n",
" # 3rd conv makes 3X3 kernels with 1 strides 64 activation map \n",
" # with \"VALID\" option, (9-3)/1 +1 = 7\n",
" # the size of activation volumn : 7X7X64 \n",
" self.conv3 = tf.contrib.layers.convolution2d( \\\n",
" inputs=self.conv2, num_outputs=64, kernel_size=[3,3],stride=[1,1],padding='VALID', biases_initializer=None)\n",
" \n",
" # 3rd conv makes 7X7 kernels with 1 strides 64 activation map \n",
" # with \"VALID\" option, (7-7)/1 +1 = 1\n",
" # the size of activation volumn : 1X1X512\n",
" self.conv4 = tf.contrib.layers.convolution2d( \\\n",
" inputs=self.conv3, num_outputs=h_size, kernel_size=[7,7],stride=[1,1],padding='VALID', biases_initializer=None)\n",
" \n",
" # We take the output from the final convolutional layer and split it into separate \"advantage\" and \"value\" streams\n",
" self.streamAC, self.streamVC = tf.split(self.conv4, 2, 3) \n",
" self.streamA = tf.contrib.layers.flatten(self.streamAC) # 1X1X256\n",
" self.streamV = tf.contrib.layers.flatten(self.streamVC) # 1X1X256\n",
" \n",
" # weight\n",
" self.AW = tf.Variable(tf.random_normal([h_size//2, env.actions])) \n",
" self.VW = tf.Variable(tf.random_normal([h_size//2, 1]))\n",
" \n",
" # \"advantage\" or \"value\" streams X \"weight\" = score\n",
" self.Advantage = tf.matmul(self.streamA, self.AW)\n",
" self.Value = tf.matmul(self.streamV, self.VW)\n",
" \n",
" # Then combine them together to get our final Q-values.\n",
" # Qout = value + (\"advantage\" - mean(\"advantage\"))\n",
" self.Qout = self.Value + tf.subtract(self.Advantage, tf.reduce_mean(self.Advantage, axis=1, keep_dims=True))\n",
" # select action by Qout\n",
" self.predict = tf.argmax(self.Qout, 1)\n",
" \n",
" self.targetQ = tf.placeholder(shape=[None],dtype=tf.float32)\n",
" self.actions = tf.placeholder(shape=[None],dtype=tf.int32)\n",
"# # to encode action to one-hot\n",
"# def one_hot_patch(x, depth):\n",
"# sparse_labels=tf.reshape(x,[-1,1])\n",
"# derived_size=tf.shape(sparse_labels)[0]\n",
"# indices=tf.reshape(tf.range(0,derived_size,1),[-1,1])\n",
"# concated=tf.concat(1,[indices,sparse_labels])\n",
"# outshape=tf.concat(0,[tf.reshape(derived_size,[1]), tf.reshape(depth,[1])])\n",
"# return tf.sparse_to_dense(concated, outshape,1.0,0.0)\n",
"# self.actions_onehot = one_hot_patch(self.actions, env.actions)\n",
" self.actions_onehot = tf.one_hot(self.actions,env.actions,dtype=tf.float32)\n",
" # Choose the Q value of action from each networks.\n",
" self.Q = tf.reduce_sum(tf.multiply(self.Qout, self.actions_onehot), axis=1)\n",
" \n",
" self.td_error = tf.square(self.targetQ - self.Q)\n",
" self.loss = tf.reduce_mean(self.td_error)\n",
" self.trainer = tf.train.AdamOptimizer(learning_rate=0.0001)\n",
" self.updateModel = self.trainer.minimize(self.loss)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Experience Replay"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"# To store experies and sample then randomly to train the network.\n",
"class experience_buffer():\n",
" def __init__(self, buffer_size = 50000):\n",
" self.buffer = []\n",
" self.buffer_size = buffer_size\n",
" \n",
" # if over buffer size, erase from first index(FIFO)\n",
" def add(self, experience):\n",
" if len(self.buffer) + len(experience) >= self.buffer_size:\n",
" self.buffer[0:(len(experience)+len(self.buffer))-self.buffer_size] = []\n",
" self.buffer.extend(experience)\n",
" \n",
" def sample(self, size):\n",
" return np.reshape(np.array(random.sample(self.buffer,size)),[size,5])\n",
"\n",
"# To re-size our game frames to scalar\n",
"def processState(states):\n",
" return np.reshape(states,[21168])\n",
"\n",
"# These functions allow us to update the parameters of our target network with those of the primary network.\n",
"def updateTargetGraph(tfVars, tau):\n",
" total_vars = len(tfVars) # trainable\n",
" op_holder = [] # operatorlist\n",
" \n",
" # tau : the rate of target network forward train layer\n",
" # split tfVars into two elements [target net.(1/2) the primary net.(1/2)]\n",
" for idx,var in enumerate(tfVars[0:total_vars//2]):\n",
" op_holder.append(tfVars[idx+total_vars//2].assign((var.value()*tau) + ((1-tau)*tfVars[idx+total_vars//2].value())))\n",
" return op_holder\n",
"\n",
"def updateTarget(op_holder, sess):\n",
" for op in op_holder:\n",
" sess.run(op)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Training the network"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# setting training parameters\n",
"batch_size = 32 # How many experiences to use for each training step.\n",
"update_freq = 4 # How often to perform a training step.\n",
"y = .99 # Discount factor on the target Q-values\n",
"\n",
"startE = 1 # Starting chance of random action\n",
"endE = 0.1 # Final chance of random action\n",
"annealing_steps = 10000. # How many steps of training to reduce startE to endE.\n",
"\n",
"num_episodes = 10000 # How many episodes of game environment to train network with.\n",
"pre_train_steps = 10000 # How many steps of random actions before training begins.\n",
"max_epLength = 50 # The max allowed length of our episode.\n",
"load_model = False # Whether to load a saved model.\n",
"path = \"./dqn\" # The path to save our model to.\n",
"h_size = 512 # The size of the final convolutional layer before splitting it into Advantage and Value streams.\n",
"tau = 0.001 # Rate to update target network toward primary network"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Saved Model\n",
"500 2.0 1\n",
"1000 2.8 1\n",
"1500 2.8 1\n",
"2000 1.2 1\n",
"2500 1.9 1\n",
"3000 1.1 1\n",
"3500 2.3 1\n",
"4000 1.2 1\n",
"4500 2.3 1\n",
"5000 3.1 1\n",
"5500 1.9 1\n",
"6000 1.7 1\n",
"6500 1.4 1\n",
"7000 3.7 1\n",
"7500 2.7 1\n",
"8000 2.6 1\n",
"8500 4.1 1\n",
"9000 2.7 1\n",
"9500 0.8 1\n",
"10000 2.0 1\n",
"10500 0.9 0.9549999999999828\n",
"11000 2.1 0.9099999999999655\n",
"11500 2.8 0.8649999999999483\n",
"12000 3.0 0.819999999999931\n",
"12500 1.5 0.7749999999999138\n",
"13000 2.9 0.7299999999998965\n",
"13500 3.0 0.6849999999998793\n",
"14000 2.2 0.639999999999862\n",
"14500 2.2 0.5949999999998448\n",
"15000 1.7 0.5499999999998275\n",
"15500 0.5 0.5049999999998103\n",
"16000 2.7 0.4599999999998177\n",
"16500 1.7 0.41499999999982823\n",
"17000 0.8 0.36999999999983874\n",
"17500 1.4 0.32499999999984924\n",
"18000 1.6 0.27999999999985975\n",
"18500 0.4 0.23499999999986562\n",
"19000 1.2 0.18999999999986225\n",
"19500 1.4 0.14499999999985888\n",
"20000 0.6 0.09999999999985551\n",
"20500 0.9 0.09999999999985551\n",
"21000 0.5 0.09999999999985551\n",
"21500 0.9 0.09999999999985551\n",
"22000 1.6 0.09999999999985551\n",
"22500 1.0 0.09999999999985551\n",
"23000 -0.1 0.09999999999985551\n",
"23500 1.0 0.09999999999985551\n",
"24000 0.2 0.09999999999985551\n",
"24500 0.2 0.09999999999985551\n",
"25000 1.4 0.09999999999985551\n",
"25500 0.7 0.09999999999985551\n",
"26000 0.1 0.09999999999985551\n",
"26500 0.0 0.09999999999985551\n",
"27000 1.7 0.09999999999985551\n",
"27500 0.3 0.09999999999985551\n",
"28000 1.4 0.09999999999985551\n",
"28500 0.5 0.09999999999985551\n",
"29000 1.4 0.09999999999985551\n",
"29500 1.5 0.09999999999985551\n",
"30000 1.1 0.09999999999985551\n",
"30500 0.3 0.09999999999985551\n",
"31000 1.6 0.09999999999985551\n",
"31500 1.0 0.09999999999985551\n",
"32000 1.0 0.09999999999985551\n",
"32500 1.0 0.09999999999985551\n",
"33000 1.0 0.09999999999985551\n",
"33500 1.1 0.09999999999985551\n",
"34000 1.5 0.09999999999985551\n",
"34500 1.0 0.09999999999985551\n",
"35000 1.4 0.09999999999985551\n",
"35500 0.4 0.09999999999985551\n",
"36000 1.6 0.09999999999985551\n",
"36500 0.4 0.09999999999985551\n",
"37000 1.4 0.09999999999985551\n",
"37500 0.6 0.09999999999985551\n",
"38000 1.4 0.09999999999985551\n",
"38500 0.4 0.09999999999985551\n",
"39000 1.6 0.09999999999985551\n",
"39500 0.8 0.09999999999985551\n",
"40000 0.6 0.09999999999985551\n",
"40500 0.7 0.09999999999985551\n",
"41000 1.0 0.09999999999985551\n",
"41500 0.9 0.09999999999985551\n",
"42000 1.0 0.09999999999985551\n",
"42500 2.0 0.09999999999985551\n",
"43000 0.7 0.09999999999985551\n",
"43500 0.6 0.09999999999985551\n",
"44000 0.5 0.09999999999985551\n",
"44500 1.4 0.09999999999985551\n",
"45000 0.0 0.09999999999985551\n",
"45500 1.1 0.09999999999985551\n",
"46000 0.6 0.09999999999985551\n",
"46500 0.9 0.09999999999985551\n",
"47000 1.3 0.09999999999985551\n",
"47500 2.3 0.09999999999985551\n",
"48000 1.5 0.09999999999985551\n",
"48500 1.9 0.09999999999985551\n",
"49000 1.1 0.09999999999985551\n",
"49500 2.1 0.09999999999985551\n",
"50000 0.7 0.09999999999985551\n",
"Saved Model\n",
"50500 0.9 0.09999999999985551\n",
"51000 0.8 0.09999999999985551\n",
"51500 1.9 0.09999999999985551\n",
"52000 1.6 0.09999999999985551\n",
"52500 1.0 0.09999999999985551\n",
"53000 1.3 0.09999999999985551\n",
"53500 1.0 0.09999999999985551\n",
"54000 1.0 0.09999999999985551\n",
"54500 0.7 0.09999999999985551\n",
"55000 0.8 0.09999999999985551\n",
"55500 1.1 0.09999999999985551\n",
"56000 1.1 0.09999999999985551\n",
"56500 2.0 0.09999999999985551\n",
"57000 0.1 0.09999999999985551\n",
"57500 0.2 0.09999999999985551\n",
"58000 0.6 0.09999999999985551\n",
"58500 0.5 0.09999999999985551\n",
"59000 0.2 0.09999999999985551\n",
"59500 1.5 0.09999999999985551\n",
"60000 1.3 0.09999999999985551\n",
"60500 1.4 0.09999999999985551\n",
"61000 1.6 0.09999999999985551\n",
"61500 1.6 0.09999999999985551\n",
"62000 1.1 0.09999999999985551\n",
"62500 1.6 0.09999999999985551\n",
"63000 1.1 0.09999999999985551\n",
"63500 1.3 0.09999999999985551\n",
"64000 1.0 0.09999999999985551\n",
"64500 1.6 0.09999999999985551\n",
"65000 0.7 0.09999999999985551\n",
"65500 1.5 0.09999999999985551\n",
"66000 1.0 0.09999999999985551\n",
"66500 0.9 0.09999999999985551\n",
"67000 1.0 0.09999999999985551\n",
"67500 0.8 0.09999999999985551\n",
"68000 1.6 0.09999999999985551\n",
"68500 0.5 0.09999999999985551\n",
"69000 0.9 0.09999999999985551\n",
"69500 1.3 0.09999999999985551\n",
"70000 1.1 0.09999999999985551\n",
"70500 0.6 0.09999999999985551\n",
"71000 0.7 0.09999999999985551\n",
"71500 2.1 0.09999999999985551\n",
"72000 1.6 0.09999999999985551\n",
"72500 1.6 0.09999999999985551\n",
"73000 1.5 0.09999999999985551\n",
"73500 1.4 0.09999999999985551\n",
"74000 0.7 0.09999999999985551\n",
"74500 2.0 0.09999999999985551\n",
"75000 1.5 0.09999999999985551\n",
"75500 1.1 0.09999999999985551\n",
"76000 1.5 0.09999999999985551\n",
"76500 1.7 0.09999999999985551\n",
"77000 1.1 0.09999999999985551\n",
"77500 2.7 0.09999999999985551\n",
"78000 1.7 0.09999999999985551\n",
"78500 0.9 0.09999999999985551\n",
"79000 1.6 0.09999999999985551\n",
"79500 1.5 0.09999999999985551\n",
"80000 1.4 0.09999999999985551\n",
"80500 1.3 0.09999999999985551\n",
"81000 2.6 0.09999999999985551\n",
"81500 2.3 0.09999999999985551\n",
"82000 2.5 0.09999999999985551\n",
"82500 2.4 0.09999999999985551\n",
"83000 1.9 0.09999999999985551\n",
"83500 2.5 0.09999999999985551\n",
"84000 2.2 0.09999999999985551\n",
"84500 2.1 0.09999999999985551\n",
"85000 2.6 0.09999999999985551\n",
"85500 2.1 0.09999999999985551\n",
"86000 1.3 0.09999999999985551\n",
"86500 1.2 0.09999999999985551\n",
"87000 3.5 0.09999999999985551\n",
"87500 1.5 0.09999999999985551\n",
"88000 2.8 0.09999999999985551\n",
"88500 3.6 0.09999999999985551\n",
"89000 2.9 0.09999999999985551\n",
"89500 0.9 0.09999999999985551\n",
"90000 1.1 0.09999999999985551\n",
"90500 2.7 0.09999999999985551\n",
"91000 2.6 0.09999999999985551\n",
"91500 1.8 0.09999999999985551\n",
"92000 1.4 0.09999999999985551\n",
"92500 1.4 0.09999999999985551\n",
"93000 2.5 0.09999999999985551\n",
"93500 2.4 0.09999999999985551\n",
"94000 2.3 0.09999999999985551\n",
"94500 2.9 0.09999999999985551\n",
"95000 2.2 0.09999999999985551\n",
"95500 2.2 0.09999999999985551\n",
"96000 2.6 0.09999999999985551\n",
"96500 4.8 0.09999999999985551\n",
"97000 2.3 0.09999999999985551\n",
"97500 2.1 0.09999999999985551\n",
"98000 2.1 0.09999999999985551\n",
"98500 4.3 0.09999999999985551\n",
"99000 2.5 0.09999999999985551\n",
"99500 3.3 0.09999999999985551\n",
"100000 3.4 0.09999999999985551\n",
"Saved Model\n",
"100500 4.0 0.09999999999985551\n",
"101000 5.0 0.09999999999985551\n",
"101500 3.2 0.09999999999985551\n",
"102000 3.1 0.09999999999985551\n",
"102500 5.5 0.09999999999985551\n",
"103000 4.8 0.09999999999985551\n",
"103500 3.4 0.09999999999985551\n",
"104000 5.6 0.09999999999985551\n",
"104500 2.6 0.09999999999985551\n",
"105000 3.9 0.09999999999985551\n",
"105500 6.4 0.09999999999985551\n",
"106000 3.8 0.09999999999985551\n",
"106500 3.0 0.09999999999985551\n",
"107000 4.9 0.09999999999985551\n",
"107500 2.9 0.09999999999985551\n",
"108000 4.6 0.09999999999985551\n",
"108500 4.2 0.09999999999985551\n",
"109000 4.5 0.09999999999985551\n",
"109500 4.8 0.09999999999985551\n",
"110000 3.9 0.09999999999985551\n",
"110500 4.7 0.09999999999985551\n",
"111000 3.6 0.09999999999985551\n",
"111500 6.5 0.09999999999985551\n",
"112000 5.0 0.09999999999985551\n",
"112500 5.5 0.09999999999985551\n",
"113000 6.2 0.09999999999985551\n",
"113500 6.4 0.09999999999985551\n",
"114000 3.6 0.09999999999985551\n",
"114500 6.1 0.09999999999985551\n",
"115000 7.0 0.09999999999985551\n",
"115500 7.6 0.09999999999985551\n",
"116000 5.6 0.09999999999985551\n",
"116500 6.7 0.09999999999985551\n",
"117000 9.0 0.09999999999985551\n",
"117500 7.0 0.09999999999985551\n",
"118000 7.0 0.09999999999985551\n",
"118500 7.1 0.09999999999985551\n",
"119000 9.1 0.09999999999985551\n",
"119500 9.1 0.09999999999985551\n",
"120000 8.5 0.09999999999985551\n",
"120500 8.9 0.09999999999985551\n",
"121000 10.1 0.09999999999985551\n",
"121500 9.8 0.09999999999985551\n",
"122000 8.9 0.09999999999985551\n",
"122500 8.8 0.09999999999985551\n",
"123000 8.6 0.09999999999985551\n",
"123500 10.8 0.09999999999985551\n",
"124000 10.1 0.09999999999985551\n",
"124500 8.6 0.09999999999985551\n",
"125000 6.4 0.09999999999985551\n",
"125500 9.8 0.09999999999985551\n",
"126000 8.3 0.09999999999985551\n",
"126500 11.1 0.09999999999985551\n",
"127000 8.4 0.09999999999985551\n",
"127500 11.9 0.09999999999985551\n",
"128000 11.1 0.09999999999985551\n",
"128500 8.4 0.09999999999985551\n",
"129000 12.2 0.09999999999985551\n",
"129500 9.1 0.09999999999985551\n",
"130000 6.6 0.09999999999985551\n",
"130500 13.2 0.09999999999985551\n",
"131000 11.6 0.09999999999985551\n",
"131500 10.4 0.09999999999985551\n",
"132000 8.9 0.09999999999985551\n",
"132500 12.2 0.09999999999985551\n",
"133000 10.6 0.09999999999985551\n",
"133500 11.6 0.09999999999985551\n",
"134000 11.3 0.09999999999985551\n",
"134500 14.6 0.09999999999985551\n",
"135000 14.2 0.09999999999985551\n",
"135500 15.5 0.09999999999985551\n",
"136000 16.1 0.09999999999985551\n",
"136500 12.4 0.09999999999985551\n",
"137000 11.7 0.09999999999985551\n",
"137500 15.3 0.09999999999985551\n",
"138000 14.9 0.09999999999985551\n",
"138500 14.2 0.09999999999985551\n",
"139000 14.8 0.09999999999985551\n",
"139500 13.9 0.09999999999985551\n",
"140000 15.6 0.09999999999985551\n",
"140500 18.1 0.09999999999985551\n",
"141000 13.9 0.09999999999985551\n",
"141500 14.9 0.09999999999985551\n",
"142000 12.2 0.09999999999985551\n",
"142500 15.5 0.09999999999985551\n",
"143000 16.5 0.09999999999985551\n",
"143500 17.2 0.09999999999985551\n",
"144000 17.0 0.09999999999985551\n",
"144500 14.6 0.09999999999985551\n",
"145000 18.3 0.09999999999985551\n",
"145500 15.5 0.09999999999985551\n",
"146000 14.2 0.09999999999985551\n",
"146500 16.6 0.09999999999985551\n",
"147000 17.8 0.09999999999985551\n",
"147500 16.4 0.09999999999985551\n",
"148000 13.3 0.09999999999985551\n",
"148500 20.9 0.09999999999985551\n",
"149000 16.0 0.09999999999985551\n",
"149500 17.4 0.09999999999985551\n",
"150000 13.8 0.09999999999985551\n",
"Saved Model\n",
"150500 18.0 0.09999999999985551\n",
"151000 18.4 0.09999999999985551\n",
"151500 18.8 0.09999999999985551\n",
"152000 17.0 0.09999999999985551\n",
"152500 18.2 0.09999999999985551\n",
"153000 15.1 0.09999999999985551\n",
"153500 15.3 0.09999999999985551\n",
"154000 18.4 0.09999999999985551\n",
"154500 15.4 0.09999999999985551\n",
"155000 19.5 0.09999999999985551\n",
"155500 18.9 0.09999999999985551\n",
"156000 18.7 0.09999999999985551\n",
"156500 19.0 0.09999999999985551\n",
"157000 17.0 0.09999999999985551\n",
"157500 15.7 0.09999999999985551\n",
"158000 19.1 0.09999999999985551\n",
"158500 20.8 0.09999999999985551\n",
"159000 17.9 0.09999999999985551\n",
"159500 18.5 0.09999999999985551\n",
"160000 21.8 0.09999999999985551\n",
"160500 18.1 0.09999999999985551\n",
"161000 21.8 0.09999999999985551\n",
"161500 19.2 0.09999999999985551\n",
"162000 19.1 0.09999999999985551\n",
"162500 18.0 0.09999999999985551\n",
"163000 17.5 0.09999999999985551\n",
"163500 16.8 0.09999999999985551\n",
"164000 18.8 0.09999999999985551\n",
"164500 18.8 0.09999999999985551\n",
"165000 20.7 0.09999999999985551\n",
"165500 18.2 0.09999999999985551\n",
"166000 18.5 0.09999999999985551\n",
"166500 19.8 0.09999999999985551\n",
"167000 21.2 0.09999999999985551\n",
"167500 18.9 0.09999999999985551\n",
"168000 21.5 0.09999999999985551\n",
"168500 23.6 0.09999999999985551\n",
"169000 20.2 0.09999999999985551\n",
"169500 21.1 0.09999999999985551\n",
"170000 20.1 0.09999999999985551\n",
"170500 22.3 0.09999999999985551\n",
"171000 18.9 0.09999999999985551\n",
"171500 16.3 0.09999999999985551\n",
"172000 21.6 0.09999999999985551\n",
"172500 17.6 0.09999999999985551\n",
"173000 20.6 0.09999999999985551\n",
"173500 21.4 0.09999999999985551\n",
"174000 20.4 0.09999999999985551\n",
"174500 21.7 0.09999999999985551\n",
"175000 21.0 0.09999999999985551\n",
"175500 23.4 0.09999999999985551\n",
"176000 17.2 0.09999999999985551\n",
"176500 19.8 0.09999999999985551\n",
"177000 22.4 0.09999999999985551\n",
"177500 21.0 0.09999999999985551\n",
"178000 18.5 0.09999999999985551\n",
"178500 21.3 0.09999999999985551\n",
"179000 21.6 0.09999999999985551\n",
"179500 21.4 0.09999999999985551\n",
"180000 20.5 0.09999999999985551\n",
"180500 20.2 0.09999999999985551\n",
"181000 19.0 0.09999999999985551\n",
"181500 20.4 0.09999999999985551\n",
"182000 20.1 0.09999999999985551\n",
"182500 21.7 0.09999999999985551\n",
"183000 21.0 0.09999999999985551\n",
"183500 22.4 0.09999999999985551\n",
"184000 19.3 0.09999999999985551\n",
"184500 21.2 0.09999999999985551\n",
"185000 15.4 0.09999999999985551\n",
"185500 17.5 0.09999999999985551\n",
"186000 17.9 0.09999999999985551\n",
"186500 23.3 0.09999999999985551\n",
"187000 18.9 0.09999999999985551\n",
"187500 22.2 0.09999999999985551\n",
"188000 19.2 0.09999999999985551\n",
"188500 19.2 0.09999999999985551\n",
"189000 19.6 0.09999999999985551\n",
"189500 21.4 0.09999999999985551\n",
"190000 19.6 0.09999999999985551\n",
"190500 20.6 0.09999999999985551\n",
"191000 19.3 0.09999999999985551\n",
"191500 20.7 0.09999999999985551\n",
"192000 19.4 0.09999999999985551\n",
"192500 22.4 0.09999999999985551\n",
"193000 20.2 0.09999999999985551\n",
"193500 19.2 0.09999999999985551\n",
"194000 20.5 0.09999999999985551\n",
"194500 21.9 0.09999999999985551\n",
"195000 20.9 0.09999999999985551\n",
"195500 22.2 0.09999999999985551\n",
"196000 20.8 0.09999999999985551\n",
"196500 21.2 0.09999999999985551\n",
"197000 21.7 0.09999999999985551\n",
"197500 22.3 0.09999999999985551\n",
"198000 21.6 0.09999999999985551\n",
"198500 21.7 0.09999999999985551\n",
"199000 22.4 0.09999999999985551\n",
"199500 23.3 0.09999999999985551\n",
"200000 21.2 0.09999999999985551\n",
"Saved Model\n",
"200500 20.1 0.09999999999985551\n",
"201000 22.7 0.09999999999985551\n",
"201500 22.2 0.09999999999985551\n",
"202000 19.3 0.09999999999985551\n",
"202500 21.8 0.09999999999985551\n",
"203000 21.6 0.09999999999985551\n",
"203500 19.1 0.09999999999985551\n",
"204000 20.8 0.09999999999985551\n",
"204500 19.9 0.09999999999985551\n",
"205000 22.0 0.09999999999985551\n",
"205500 21.6 0.09999999999985551\n",
"206000 18.5 0.09999999999985551\n",
"206500 21.0 0.09999999999985551\n",
"207000 21.1 0.09999999999985551\n",
"207500 19.1 0.09999999999985551\n",
"208000 22.0 0.09999999999985551\n",
"208500 23.8 0.09999999999985551\n",
"209000 19.8 0.09999999999985551\n",
"209500 23.9 0.09999999999985551\n",
"210000 22.7 0.09999999999985551\n",
"210500 22.4 0.09999999999985551\n",
"211000 19.1 0.09999999999985551\n",
"211500 20.1 0.09999999999985551\n",
"212000 22.0 0.09999999999985551\n",
"212500 19.8 0.09999999999985551\n",
"213000 20.5 0.09999999999985551\n",
"213500 22.1 0.09999999999985551\n",
"214000 20.6 0.09999999999985551\n",
"214500 22.0 0.09999999999985551\n",
"215000 22.6 0.09999999999985551\n",
"215500 21.3 0.09999999999985551\n",
"216000 23.1 0.09999999999985551\n",
"216500 23.0 0.09999999999985551\n",
"217000 23.4 0.09999999999985551\n",
"217500 23.4 0.09999999999985551\n",
"218000 23.6 0.09999999999985551\n",
"218500 22.7 0.09999999999985551\n",
"219000 22.8 0.09999999999985551\n",
"219500 22.3 0.09999999999985551\n",
"220000 22.9 0.09999999999985551\n",
"220500 22.9 0.09999999999985551\n",
"221000 23.2 0.09999999999985551\n",
"221500 21.1 0.09999999999985551\n",
"222000 20.7 0.09999999999985551\n",
"222500 20.2 0.09999999999985551\n",
"223000 21.0 0.09999999999985551\n",
"223500 21.8 0.09999999999985551\n",
"224000 22.4 0.09999999999985551\n",
"224500 21.3 0.09999999999985551\n",
"225000 21.9 0.09999999999985551\n",
"225500 21.9 0.09999999999985551\n",
"226000 24.0 0.09999999999985551\n",
"226500 22.5 0.09999999999985551\n",
"227000 22.9 0.09999999999985551\n",
"227500 17.5 0.09999999999985551\n",
"228000 19.1 0.09999999999985551\n",
"228500 22.3 0.09999999999985551\n",
"229000 22.2 0.09999999999985551\n",
"229500 22.2 0.09999999999985551\n",
"230000 21.3 0.09999999999985551\n",
"230500 20.6 0.09999999999985551\n",
"231000 22.9 0.09999999999985551\n",
"231500 23.5 0.09999999999985551\n",
"232000 22.0 0.09999999999985551\n",
"232500 20.6 0.09999999999985551\n",
"233000 22.5 0.09999999999985551\n",
"233500 22.4 0.09999999999985551\n",
"234000 19.7 0.09999999999985551\n",
"234500 20.0 0.09999999999985551\n",
"235000 21.3 0.09999999999985551\n",
"235500 22.3 0.09999999999985551\n",
"236000 19.7 0.09999999999985551\n",
"236500 22.4 0.09999999999985551\n",
"237000 22.2 0.09999999999985551\n",
"237500 21.8 0.09999999999985551\n",
"238000 21.6 0.09999999999985551\n",
"238500 23.9 0.09999999999985551\n",
"239000 19.9 0.09999999999985551\n",
"239500 20.5 0.09999999999985551\n",
"240000 18.9 0.09999999999985551\n",
"240500 20.5 0.09999999999985551\n",
"241000 23.7 0.09999999999985551\n",
"241500 21.0 0.09999999999985551\n",
"242000 22.6 0.09999999999985551\n",
"242500 24.5 0.09999999999985551\n",
"243000 22.3 0.09999999999985551\n",
"243500 24.3 0.09999999999985551\n",
"244000 23.6 0.09999999999985551\n",
"244500 24.0 0.09999999999985551\n",
"245000 22.3 0.09999999999985551\n",
"245500 21.5 0.09999999999985551\n",
"246000 22.1 0.09999999999985551\n",
"246500 20.2 0.09999999999985551\n",
"247000 21.5 0.09999999999985551\n",
"247500 21.4 0.09999999999985551\n",
"248000 19.5 0.09999999999985551\n",
"248500 22.0 0.09999999999985551\n",
"249000 21.2 0.09999999999985551\n",
"249500 22.9 0.09999999999985551\n",
"250000 22.9 0.09999999999985551\n",
"Saved Model\n",
"250500 20.2 0.09999999999985551\n",
"251000 22.1 0.09999999999985551\n",
"251500 22.9 0.09999999999985551\n",
"252000 20.4 0.09999999999985551\n",
"252500 20.4 0.09999999999985551\n",
"253000 22.0 0.09999999999985551\n",
"253500 21.0 0.09999999999985551\n",
"254000 22.0 0.09999999999985551\n",
"254500 20.9 0.09999999999985551\n",
"255000 23.1 0.09999999999985551\n",
"255500 21.7 0.09999999999985551\n",
"256000 20.8 0.09999999999985551\n",
"256500 20.9 0.09999999999985551\n",
"257000 21.0 0.09999999999985551\n",
"257500 22.1 0.09999999999985551\n",
"258000 20.4 0.09999999999985551\n",
"258500 21.9 0.09999999999985551\n",
"259000 22.3 0.09999999999985551\n",
"259500 22.5 0.09999999999985551\n",
"260000 23.0 0.09999999999985551\n",
"260500 22.3 0.09999999999985551\n",
"261000 22.6 0.09999999999985551\n",
"261500 23.8 0.09999999999985551\n",
"262000 22.7 0.09999999999985551\n",
"262500 24.0 0.09999999999985551\n",
"263000 24.1 0.09999999999985551\n",
"263500 22.6 0.09999999999985551\n",
"264000 22.8 0.09999999999985551\n",
"264500 22.5 0.09999999999985551\n",
"265000 21.4 0.09999999999985551\n",
"265500 19.9 0.09999999999985551\n",
"266000 22.2 0.09999999999985551\n",
"266500 22.1 0.09999999999985551\n",
"267000 22.7 0.09999999999985551\n",
"267500 21.7 0.09999999999985551\n",
"268000 23.1 0.09999999999985551\n",
"268500 21.7 0.09999999999985551\n",
"269000 23.3 0.09999999999985551\n",
"269500 21.9 0.09999999999985551\n",
"270000 22.7 0.09999999999985551\n",
"270500 23.3 0.09999999999985551\n",
"271000 22.3 0.09999999999985551\n",
"271500 22.9 0.09999999999985551\n",
"272000 20.4 0.09999999999985551\n",
"272500 20.5 0.09999999999985551\n",
"273000 22.3 0.09999999999985551\n",
"273500 23.9 0.09999999999985551\n",
"274000 22.2 0.09999999999985551\n",
"274500 22.3 0.09999999999985551\n",
"275000 21.9 0.09999999999985551\n",
"275500 23.2 0.09999999999985551\n",
"276000 23.2 0.09999999999985551\n",
"276500 21.2 0.09999999999985551\n",
"277000 21.5 0.09999999999985551\n",
"277500 22.5 0.09999999999985551\n",
"278000 22.4 0.09999999999985551\n",
"278500 23.0 0.09999999999985551\n",
"279000 23.3 0.09999999999985551\n",
"279500 19.2 0.09999999999985551\n",
"280000 22.2 0.09999999999985551\n",
"280500 23.1 0.09999999999985551\n",
"281000 21.3 0.09999999999985551\n",
"281500 22.6 0.09999999999985551\n",
"282000 23.0 0.09999999999985551\n",
"282500 21.1 0.09999999999985551\n",
"283000 23.2 0.09999999999985551\n",
"283500 22.5 0.09999999999985551\n",
"284000 19.3 0.09999999999985551\n",
"284500 21.9 0.09999999999985551\n",
"285000 21.3 0.09999999999985551\n",
"285500 22.9 0.09999999999985551\n",
"286000 23.9 0.09999999999985551\n",
"286500 22.7 0.09999999999985551\n",
"287000 22.4 0.09999999999985551\n",
"287500 18.6 0.09999999999985551\n",
"288000 20.9 0.09999999999985551\n",
"288500 21.5 0.09999999999985551\n",
"289000 21.7 0.09999999999985551\n",
"289500 21.6 0.09999999999985551\n",
"290000 21.2 0.09999999999985551\n",
"290500 20.6 0.09999999999985551\n",
"291000 21.7 0.09999999999985551\n",
"291500 20.8 0.09999999999985551\n",
"292000 21.6 0.09999999999985551\n",
"292500 22.3 0.09999999999985551\n",
"293000 22.0 0.09999999999985551\n",
"293500 21.9 0.09999999999985551\n",
"294000 23.2 0.09999999999985551\n",
"294500 22.3 0.09999999999985551\n",
"295000 22.2 0.09999999999985551\n",
"295500 21.7 0.09999999999985551\n",
"296000 23.2 0.09999999999985551\n",
"296500 24.1 0.09999999999985551\n",
"297000 21.7 0.09999999999985551\n",
"297500 22.3 0.09999999999985551\n",
"298000 22.9 0.09999999999985551\n",
"298500 22.8 0.09999999999985551\n",
"299000 22.2 0.09999999999985551\n",
"299500 22.6 0.09999999999985551\n",
"300000 23.3 0.09999999999985551\n",
"Saved Model\n",
"300500 24.8 0.09999999999985551\n",
"301000 22.0 0.09999999999985551\n",
"301500 20.6 0.09999999999985551\n",
"302000 20.5 0.09999999999985551\n",
"302500 24.2 0.09999999999985551\n",
"303000 24.2 0.09999999999985551\n",
"303500 20.6 0.09999999999985551\n",
"304000 21.6 0.09999999999985551\n",
"304500 22.4 0.09999999999985551\n",
"305000 20.8 0.09999999999985551\n",
"305500 22.6 0.09999999999985551\n",
"306000 23.4 0.09999999999985551\n",
"306500 22.2 0.09999999999985551\n",
"307000 20.4 0.09999999999985551\n",
"307500 22.1 0.09999999999985551\n",
"308000 23.2 0.09999999999985551\n",
"308500 20.1 0.09999999999985551\n",
"309000 22.2 0.09999999999985551\n",
"309500 21.6 0.09999999999985551\n",
"310000 23.1 0.09999999999985551\n",
"310500 23.9 0.09999999999985551\n",
"311000 21.1 0.09999999999985551\n",
"311500 21.0 0.09999999999985551\n",
"312000 20.9 0.09999999999985551\n",
"312500 23.7 0.09999999999985551\n",
"313000 22.2 0.09999999999985551\n",
"313500 21.0 0.09999999999985551\n",
"314000 23.4 0.09999999999985551\n",
"314500 22.1 0.09999999999985551\n",
"315000 21.3 0.09999999999985551\n",
"315500 22.3 0.09999999999985551\n",
"316000 22.5 0.09999999999985551\n",
"316500 19.1 0.09999999999985551\n",
"317000 23.9 0.09999999999985551\n",
"317500 22.2 0.09999999999985551\n",
"318000 23.3 0.09999999999985551\n",
"318500 23.2 0.09999999999985551\n",
"319000 21.0 0.09999999999985551\n",
"319500 22.8 0.09999999999985551\n",
"320000 22.6 0.09999999999985551\n",
"320500 22.4 0.09999999999985551\n",
"321000 21.5 0.09999999999985551\n",
"321500 24.1 0.09999999999985551\n",
"322000 21.1 0.09999999999985551\n",
"322500 21.7 0.09999999999985551\n",
"323000 23.1 0.09999999999985551\n",
"323500 21.9 0.09999999999985551\n",
"324000 22.3 0.09999999999985551\n",
"324500 23.6 0.09999999999985551\n",
"325000 20.8 0.09999999999985551\n",
"325500 17.9 0.09999999999985551\n",
"326000 22.1 0.09999999999985551\n",
"326500 22.3 0.09999999999985551\n",
"327000 23.6 0.09999999999985551\n",
"327500 19.6 0.09999999999985551\n",
"328000 23.8 0.09999999999985551\n",
"328500 23.8 0.09999999999985551\n",
"329000 22.3 0.09999999999985551\n",
"329500 24.3 0.09999999999985551\n",
"330000 23.7 0.09999999999985551\n",
"330500 22.2 0.09999999999985551\n",
"331000 23.5 0.09999999999985551\n",
"331500 23.8 0.09999999999985551\n",
"332000 22.8 0.09999999999985551\n",
"332500 21.2 0.09999999999985551\n",
"333000 20.0 0.09999999999985551\n",
"333500 22.7 0.09999999999985551\n",
"334000 22.0 0.09999999999985551\n",
"334500 20.1 0.09999999999985551\n",
"335000 22.9 0.09999999999985551\n",
"335500 24.6 0.09999999999985551\n",
"336000 22.3 0.09999999999985551\n",
"336500 20.5 0.09999999999985551\n",
"337000 20.8 0.09999999999985551\n",
"337500 23.4 0.09999999999985551\n",
"338000 23.2 0.09999999999985551\n",
"338500 24.5 0.09999999999985551\n",
"339000 20.5 0.09999999999985551\n",
"339500 22.5 0.09999999999985551\n",
"340000 23.2 0.09999999999985551\n",
"340500 23.1 0.09999999999985551\n",
"341000 21.3 0.09999999999985551\n",
"341500 21.7 0.09999999999985551\n",
"342000 20.6 0.09999999999985551\n",
"342500 23.4 0.09999999999985551\n",
"343000 23.4 0.09999999999985551\n",
"343500 23.3 0.09999999999985551\n",
"344000 25.1 0.09999999999985551\n",
"344500 22.5 0.09999999999985551\n",
"345000 23.0 0.09999999999985551\n",
"345500 20.5 0.09999999999985551\n",
"346000 20.7 0.09999999999985551\n",
"346500 22.6 0.09999999999985551\n",
"347000 22.8 0.09999999999985551\n",
"347500 24.5 0.09999999999985551\n",
"348000 21.5 0.09999999999985551\n",
"348500 22.0 0.09999999999985551\n",
"349000 23.2 0.09999999999985551\n",
"349500 23.0 0.09999999999985551\n",
"350000 23.4 0.09999999999985551\n",
"Saved Model\n",
"350500 23.0 0.09999999999985551\n",
"351000 21.7 0.09999999999985551\n",
"351500 23.4 0.09999999999985551\n",
"352000 21.6 0.09999999999985551\n",
"352500 22.5 0.09999999999985551\n",
"353000 24.3 0.09999999999985551\n",
"353500 22.6 0.09999999999985551\n",
"354000 21.5 0.09999999999985551\n",
"354500 22.9 0.09999999999985551\n",
"355000 19.3 0.09999999999985551\n",
"355500 22.9 0.09999999999985551\n",
"356000 21.9 0.09999999999985551\n",
"356500 22.0 0.09999999999985551\n",
"357000 22.3 0.09999999999985551\n",
"357500 21.7 0.09999999999985551\n",
"358000 21.2 0.09999999999985551\n",
"358500 19.8 0.09999999999985551\n",
"359000 23.0 0.09999999999985551\n",
"359500 23.9 0.09999999999985551\n",
"360000 21.6 0.09999999999985551\n",
"360500 20.4 0.09999999999985551\n",
"361000 23.1 0.09999999999985551\n",
"361500 23.6 0.09999999999985551\n",
"362000 22.4 0.09999999999985551\n",
"362500 21.7 0.09999999999985551\n",
"363000 24.1 0.09999999999985551\n",
"363500 22.4 0.09999999999985551\n",
"364000 22.7 0.09999999999985551\n",
"364500 23.2 0.09999999999985551\n",
"365000 23.8 0.09999999999985551\n",
"365500 23.7 0.09999999999985551\n",
"366000 21.3 0.09999999999985551\n",
"366500 23.6 0.09999999999985551\n",
"367000 23.6 0.09999999999985551\n",
"367500 23.9 0.09999999999985551\n",
"368000 23.7 0.09999999999985551\n",
"368500 18.9 0.09999999999985551\n",
"369000 23.4 0.09999999999985551\n",
"369500 24.6 0.09999999999985551\n",
"370000 22.8 0.09999999999985551\n",
"370500 21.8 0.09999999999985551\n",
"371000 22.5 0.09999999999985551\n",
"371500 24.7 0.09999999999985551\n",
"372000 23.1 0.09999999999985551\n",
"372500 23.4 0.09999999999985551\n",
"373000 22.0 0.09999999999985551\n",
"373500 24.1 0.09999999999985551\n",
"374000 19.0 0.09999999999985551\n",
"374500 20.1 0.09999999999985551\n",
"375000 23.1 0.09999999999985551\n",
"375500 21.7 0.09999999999985551\n",
"376000 22.9 0.09999999999985551\n",
"376500 23.6 0.09999999999985551\n",
"377000 22.3 0.09999999999985551\n",
"377500 22.6 0.09999999999985551\n",
"378000 24.1 0.09999999999985551\n",
"378500 22.1 0.09999999999985551\n",
"379000 23.9 0.09999999999985551\n",
"379500 21.4 0.09999999999985551\n",
"380000 21.2 0.09999999999985551\n",
"380500 24.6 0.09999999999985551\n",
"381000 23.2 0.09999999999985551\n",
"381500 22.6 0.09999999999985551\n",
"382000 20.3 0.09999999999985551\n",
"382500 21.5 0.09999999999985551\n",
"383000 23.1 0.09999999999985551\n",
"383500 22.8 0.09999999999985551\n",
"384000 22.5 0.09999999999985551\n",
"384500 22.6 0.09999999999985551\n",
"385000 22.0 0.09999999999985551\n",
"385500 23.5 0.09999999999985551\n",
"386000 24.1 0.09999999999985551\n",
"386500 21.7 0.09999999999985551\n",
"387000 22.2 0.09999999999985551\n",
"387500 21.7 0.09999999999985551\n",
"388000 22.4 0.09999999999985551\n",
"388500 22.8 0.09999999999985551\n",
"389000 23.0 0.09999999999985551\n",
"389500 22.3 0.09999999999985551\n",
"390000 20.3 0.09999999999985551\n",
"390500 25.2 0.09999999999985551\n",
"391000 22.5 0.09999999999985551\n",
"391500 22.2 0.09999999999985551\n",
"392000 21.7 0.09999999999985551\n",
"392500 24.4 0.09999999999985551\n",
"393000 21.7 0.09999999999985551\n",
"393500 22.4 0.09999999999985551\n",
"394000 23.7 0.09999999999985551\n",
"394500 22.3 0.09999999999985551\n",
"395000 23.4 0.09999999999985551\n",
"395500 22.9 0.09999999999985551\n",
"396000 22.0 0.09999999999985551\n",
"396500 21.4 0.09999999999985551\n",
"397000 21.2 0.09999999999985551\n",
"397500 21.6 0.09999999999985551\n",
"398000 24.2 0.09999999999985551\n",
"398500 23.1 0.09999999999985551\n",
"399000 23.5 0.09999999999985551\n",
"399500 25.6 0.09999999999985551\n",
"400000 22.8 0.09999999999985551\n",
"Saved Model\n",
"400500 23.2 0.09999999999985551\n",
"401000 23.9 0.09999999999985551\n",
"401500 22.6 0.09999999999985551\n",
"402000 22.0 0.09999999999985551\n",
"402500 23.1 0.09999999999985551\n",
"403000 22.0 0.09999999999985551\n",
"403500 22.3 0.09999999999985551\n",
"404000 23.9 0.09999999999985551\n",
"404500 22.3 0.09999999999985551\n",
"405000 23.5 0.09999999999985551\n",
"405500 20.3 0.09999999999985551\n",
"406000 23.0 0.09999999999985551\n",
"406500 20.1 0.09999999999985551\n",
"407000 22.3 0.09999999999985551\n",
"407500 23.1 0.09999999999985551\n",
"408000 24.9 0.09999999999985551\n",
"408500 23.0 0.09999999999985551\n",
"409000 23.8 0.09999999999985551\n",
"409500 23.2 0.09999999999985551\n",
"410000 23.8 0.09999999999985551\n",
"410500 22.6 0.09999999999985551\n",
"411000 25.3 0.09999999999985551\n",
"411500 21.4 0.09999999999985551\n",
"412000 21.7 0.09999999999985551\n",
"412500 22.0 0.09999999999985551\n",
"413000 24.2 0.09999999999985551\n",
"413500 23.6 0.09999999999985551\n",
"414000 25.0 0.09999999999985551\n",
"414500 23.5 0.09999999999985551\n",
"415000 23.8 0.09999999999985551\n",
"415500 21.9 0.09999999999985551\n",
"416000 21.8 0.09999999999985551\n",
"416500 23.1 0.09999999999985551\n",
"417000 23.4 0.09999999999985551\n",
"417500 23.1 0.09999999999985551\n",
"418000 23.5 0.09999999999985551\n",
"418500 22.1 0.09999999999985551\n",
"419000 22.9 0.09999999999985551\n",
"419500 22.1 0.09999999999985551\n",
"420000 23.3 0.09999999999985551\n",
"420500 22.0 0.09999999999985551\n",
"421000 24.0 0.09999999999985551\n",
"421500 23.0 0.09999999999985551\n",
"422000 19.9 0.09999999999985551\n",
"422500 22.2 0.09999999999985551\n",
"423000 22.7 0.09999999999985551\n",
"423500 22.7 0.09999999999985551\n",
"424000 23.2 0.09999999999985551\n",
"424500 24.1 0.09999999999985551\n",
"425000 23.3 0.09999999999985551\n",
"425500 23.1 0.09999999999985551\n",
"426000 22.2 0.09999999999985551\n",
"426500 24.0 0.09999999999985551\n",
"427000 23.9 0.09999999999985551\n",
"427500 21.8 0.09999999999985551\n",
"428000 23.4 0.09999999999985551\n",
"428500 20.7 0.09999999999985551\n",
"429000 20.2 0.09999999999985551\n",
"429500 20.0 0.09999999999985551\n",
"430000 23.3 0.09999999999985551\n",
"430500 24.2 0.09999999999985551\n",
"431000 24.2 0.09999999999985551\n",
"431500 23.4 0.09999999999985551\n",
"432000 22.0 0.09999999999985551\n",
"432500 24.1 0.09999999999985551\n",
"433000 23.0 0.09999999999985551\n",
"433500 21.8 0.09999999999985551\n",
"434000 23.1 0.09999999999985551\n",
"434500 20.4 0.09999999999985551\n",
"435000 22.5 0.09999999999985551\n",
"435500 22.9 0.09999999999985551\n",
"436000 20.2 0.09999999999985551\n",
"436500 22.3 0.09999999999985551\n",
"437000 21.3 0.09999999999985551\n",
"437500 22.3 0.09999999999985551\n",
"438000 23.7 0.09999999999985551\n",
"438500 22.4 0.09999999999985551\n",
"439000 23.8 0.09999999999985551\n",
"439500 22.5 0.09999999999985551\n",
"440000 22.8 0.09999999999985551\n",
"440500 22.1 0.09999999999985551\n",
"441000 22.7 0.09999999999985551\n",
"441500 22.0 0.09999999999985551\n",
"442000 23.1 0.09999999999985551\n",
"442500 23.5 0.09999999999985551\n",
"443000 20.0 0.09999999999985551\n",
"443500 22.0 0.09999999999985551\n",
"444000 23.5 0.09999999999985551\n",
"444500 22.8 0.09999999999985551\n",
"445000 24.2 0.09999999999985551\n",
"445500 22.4 0.09999999999985551\n",
"446000 20.9 0.09999999999985551\n",
"446500 23.6 0.09999999999985551\n",
"447000 22.0 0.09999999999985551\n",
"447500 22.2 0.09999999999985551\n",
"448000 21.3 0.09999999999985551\n",
"448500 23.8 0.09999999999985551\n",
"449000 21.9 0.09999999999985551\n",
"449500 24.4 0.09999999999985551\n",
"450000 24.8 0.09999999999985551\n",
"Saved Model\n",
"450500 22.7 0.09999999999985551\n",
"451000 21.6 0.09999999999985551\n",
"451500 20.3 0.09999999999985551\n",
"452000 23.2 0.09999999999985551\n",
"452500 22.5 0.09999999999985551\n",
"453000 20.4 0.09999999999985551\n",
"453500 23.7 0.09999999999985551\n",
"454000 22.8 0.09999999999985551\n",
"454500 22.3 0.09999999999985551\n",
"455000 22.1 0.09999999999985551\n",
"455500 20.8 0.09999999999985551\n",
"456000 20.9 0.09999999999985551\n",
"456500 21.1 0.09999999999985551\n",
"457000 21.8 0.09999999999985551\n",
"457500 22.8 0.09999999999985551\n",
"458000 24.2 0.09999999999985551\n",
"458500 22.6 0.09999999999985551\n",
"459000 23.1 0.09999999999985551\n",
"459500 21.7 0.09999999999985551\n",
"460000 25.4 0.09999999999985551\n",
"460500 25.4 0.09999999999985551\n",
"461000 22.3 0.09999999999985551\n",
"461500 25.2 0.09999999999985551\n",
"462000 21.9 0.09999999999985551\n",
"462500 24.4 0.09999999999985551\n",
"463000 23.5 0.09999999999985551\n",
"463500 21.4 0.09999999999985551\n",
"464000 24.2 0.09999999999985551\n",
"464500 22.6 0.09999999999985551\n",
"465000 20.1 0.09999999999985551\n",
"465500 22.9 0.09999999999985551\n",
"466000 22.9 0.09999999999985551\n",
"466500 24.8 0.09999999999985551\n",
"467000 23.3 0.09999999999985551\n",
"467500 22.1 0.09999999999985551\n",
"468000 23.3 0.09999999999985551\n",
"468500 20.0 0.09999999999985551\n",
"469000 21.1 0.09999999999985551\n",
"469500 24.0 0.09999999999985551\n",
"470000 22.5 0.09999999999985551\n",
"470500 20.3 0.09999999999985551\n",
"471000 23.1 0.09999999999985551\n",
"471500 22.7 0.09999999999985551\n",
"472000 21.9 0.09999999999985551\n",
"472500 23.0 0.09999999999985551\n",
"473000 23.2 0.09999999999985551\n",
"473500 22.7 0.09999999999985551\n",
"474000 21.7 0.09999999999985551\n",
"474500 23.0 0.09999999999985551\n",
"475000 23.4 0.09999999999985551\n",
"475500 22.6 0.09999999999985551\n",
"476000 22.5 0.09999999999985551\n",
"476500 22.2 0.09999999999985551\n",
"477000 24.0 0.09999999999985551\n",
"477500 24.2 0.09999999999985551\n",
"478000 21.3 0.09999999999985551\n",
"478500 23.5 0.09999999999985551\n",
"479000 22.9 0.09999999999985551\n",
"479500 20.3 0.09999999999985551\n",
"480000 22.2 0.09999999999985551\n",
"480500 23.1 0.09999999999985551\n",
"481000 23.1 0.09999999999985551\n",
"481500 22.5 0.09999999999985551\n",
"482000 22.7 0.09999999999985551\n",
"482500 19.7 0.09999999999985551\n",
"483000 24.1 0.09999999999985551\n",
"483500 23.1 0.09999999999985551\n",
"484000 22.3 0.09999999999985551\n",
"484500 22.9 0.09999999999985551\n",
"485000 21.3 0.09999999999985551\n",
"485500 22.7 0.09999999999985551\n",
"486000 22.1 0.09999999999985551\n",
"486500 21.1 0.09999999999985551\n",
"487000 23.9 0.09999999999985551\n",
"487500 22.9 0.09999999999985551\n",
"488000 21.8 0.09999999999985551\n",
"488500 23.1 0.09999999999985551\n",
"489000 21.3 0.09999999999985551\n",
"489500 22.2 0.09999999999985551\n",
"490000 23.0 0.09999999999985551\n",
"490500 24.3 0.09999999999985551\n",
"491000 22.9 0.09999999999985551\n",
"491500 24.3 0.09999999999985551\n",
"492000 24.0 0.09999999999985551\n",
"492500 22.4 0.09999999999985551\n",
"493000 23.0 0.09999999999985551\n",
"493500 22.4 0.09999999999985551\n",
"494000 22.7 0.09999999999985551\n",
"494500 25.2 0.09999999999985551\n",
"495000 20.5 0.09999999999985551\n",
"495500 20.9 0.09999999999985551\n",
"496000 23.4 0.09999999999985551\n",
"496500 21.0 0.09999999999985551\n",
"497000 21.6 0.09999999999985551\n",
"497500 22.7 0.09999999999985551\n",
"498000 23.0 0.09999999999985551\n",
"498500 24.2 0.09999999999985551\n",
"499000 22.3 0.09999999999985551\n",
"499500 19.8 0.09999999999985551\n",
"500000 23.4 0.09999999999985551\n",
"Percent of succesful episodes: 16.6686%\n"
]
}
],
"source": [
"tf.reset_default_graph()\n",
"mainQN = Qnetwork(h_size) # the primary net.\n",
"targetQN = Qnetwork(h_size) # target net.\n",
"\n",
"init = tf.global_variables_initializer()\n",
"saver = tf.train.Saver() # save model\n",
"trainables = tf.trainable_variables()\n",
"targetOps = updateTargetGraph(trainables, tau)\n",
"\n",
"myBuffer = experience_buffer()\n",
"\n",
"# Set the rate of random action decrease.\n",
"e = startE # setε\n",
"stepDrop = (startE - endE)/annealing_steps # decaying ε to endE\n",
"\n",
"# Create lists to contain total rewards and steps per episode\n",
"jList = []\n",
"rList = []\n",
"total_steps = 0\n",
"\n",
"# Make a path for our model to be saved in.\n",
"if not os.path.exists(path):\n",
" os.makedirs(path)\n",
"\n",
"with tf.Session() as sess:\n",
" # Check for loading a model\n",
" if load_model == True:\n",
" print('Loading Model...')\n",
" ckpt = tf.train.get_checkpoint_state(path)\n",
" saver.restore(sess,ckpt.model_checkpoint_path)\n",
" \n",
" sess.run(init)\n",
" updateTarget(targetOps, sess)\n",
" for i in range(num_episodes):\n",
" episodeBuffer = experience_buffer()\n",
" \n",
" # Reset environment and get first new observation\n",
" s = env.reset()\n",
" s = processState(s)\n",
" d = False\n",
" rAll = 0\n",
" j = 0\n",
" \n",
" # The Q-Network\n",
" while j < max_epLength: # If the agent takes longer than 50 moves to reach either of the blocks, end the trial.\n",
" j+=1\n",
" \n",
" # Choose an action by greedily (with e chance of random action) from the Q-network\n",
" if np.random.rand(1) < e or total_steps < pre_train_steps:\n",
" a = np.random.randint(0,4)\n",
" else:\n",
" a = sess.run(mainQN.predict,feed_dict={mainQN.scalarInput:[s]})[0] # get Q-value from neural net\n",
" s1,r,d = env.step(a)\n",
" s1 = processState(s1)\n",
" total_steps += 1\n",
" episodeBuffer.add(np.reshape(np.array([s,a,r,s1,d]),[1,5])) #Save the experience to our episode buffer.\n",
" \n",
" if total_steps > pre_train_steps:\n",
" if e > endE:\n",
" e -= stepDrop\n",
" \n",
" if total_steps % (update_freq) == 0:\n",
" trainBatch = myBuffer.sample(batch_size) # Get a random batch of experiences.\n",
" \n",
" # Below we perform the Double-DQN update to the target Q-values\n",
" Q1 = sess.run(mainQN.predict,feed_dict={mainQN.scalarInput:np.vstack(trainBatch[:,3])})\n",
" Q2 = sess.run(targetQN.Qout,feed_dict={targetQN.scalarInput:np.vstack(trainBatch[:,3])})\n",
" end_multiplier = -(trainBatch[:,4] - 1)\n",
" doubleQ = Q2[range(batch_size),Q1]\n",
" targetQ = trainBatch[:,2] + (y*doubleQ * end_multiplier) # immidiate + the next max reawrd(doubleQ)\n",
" \n",
" # Update the network with our target values.\n",
" _ = sess.run(mainQN.updateModel, \\\n",
" feed_dict={mainQN.scalarInput:np.vstack(trainBatch[:,0]), mainQN.targetQ:targetQ, mainQN.actions:trainBatch[:,1]})\n",
" \n",
" # Update the target network toward the primary network. \n",
" # the primary net applied as much as the rate of tau\n",
" updateTarget(targetOps,sess) \n",
" rAll += r\n",
" s = s1\n",
" \n",
" if d == True:\n",
" break\n",
" \n",
" myBuffer.add(episodeBuffer.buffer)\n",
" jList.append(j)\n",
" rList.append(rAll)\n",
" \n",
" # Periodically save the model. \n",
" if i % 1000 == 0:\n",
" saver.save(sess,path+'/model-'+str(i)+'.ckpt')\n",
" print(\"Saved Model\")\n",
" \n",
" # print avg(reward) per recent 10 episodes \n",
" if len(rList) % 10 == 0:\n",
" print('(total_steps, np.mean(rList[-10:]), e)')\n",
" \n",
" # save model\n",
" saver.save(sess,path+'/model-'+str(i)+'.ckpt')\n",
" \n",
"print(\"Percent of succesful episodes: \" + str(sum(rList)/num_episodes) + \"%\")"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment