Commit 94189629 authored by Vikram Waradpande's avatar Vikram Waradpande
Browse files

Add DW embeds

parent 572fa273
......@@ -107,9 +107,9 @@ BATCH_SIZE = 50
#Save params
state_index = -1
rew_arr = []
rewardAxis = np.zeros((10,60))
stepsAxis = np.zeros((10,60))
partRew = [[] for i in range(10)]
rewardAxis = np.zeros((20,60))
stepsAxis = np.zeros((20,60))
partRew = [[] for i in range(20)]
globalTotSteps = 0
......
......@@ -63,7 +63,7 @@ START_STATE = 1
MAX_EPISODES = 60
EMBTOGGLE = 1
DIMENSION = 30
TARGET_LOC = 370
TARGET_LOC = 390
LOAD_TRAINED_MODEL_PATH = ""
......@@ -97,8 +97,8 @@ BATCH_SIZE = 50
#Save params
state_index = -1
rew_arr = []
rewardAxis = np.zeros((20,60))
stepsAxis = np.zeros((20,60))
rewardAxis = np.zeros((10,60))
stepsAxis = np.zeros((10,60))
partRew = [[] for i in range(20)]
......@@ -192,9 +192,9 @@ class Environment:
self.dimension = DIMENSION
self.cs = 0
self.model1 = KeyedVectors.load_word2vec_format(
'./Embeddings/maze7_src_30.txt', binary=False)
'./Embeddings/maze6_src_30.txt', binary=False)
self.model2 = KeyedVectors.load_word2vec_format(
'./Embeddings/maze7_dst_30.txt', binary=False)
'./Embeddings/maze6_dst_30.txt', binary=False)
self.DLToggle = 0
def _create_map(self, row_number, col_number):
......@@ -471,6 +471,7 @@ def deepQLearning(model, env, state, randomMode=False, **opt):
# Apply action, get reward and new envstate
next_state, reward, game_status = env.act(action)
totRew += reward
ns = (env.generate_embedding()).reshape((1, -1))
......@@ -646,7 +647,7 @@ def trainDQN():
state_index = -1
for _ in range(20):
for _ in range(10):
state = 5
if state in obstacles_loc or state == TARGET_LOC:
......@@ -673,9 +674,9 @@ def trainDQN():
pass
partRew = np.array(partRew)
np.save('./Results/LargerMazes/maze7_30APP_1.npy',rewardAxis)
np.save('./Results/Steps/maze7_30APP_1.npy',stepsAxis)
np.save('./Results/Rews/maze7_30APP_1.npy',partRew)
np.save('./Results/LargerMazes/maze6_30APP_5.npy',rewardAxis)
np.save('./Results/Steps/maze6_30APP_5.npy',stepsAxis)
np.save('./Results/Rews/maze6_30APP_5.npy',partRew)
if __name__ == "__main__":
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,6 +2,7 @@ import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
import matplotlib.pyplot as plt
import random
import seaborn as sns
sns.set()
......@@ -10,7 +11,7 @@ def transformData(arr):
a = []
print(len(arr))
for i in range(len(arr)):
for j in range(20):
for j in range(15):
a.append([i, j, arr[i][j]])
return a
......@@ -22,19 +23,25 @@ def transformData2(arr):
a.append([i,j])
return a
# rews1 = np.load('./Results/Rews/maze6_30glae_1.npy')
# rews2 = np.load('./Results/Rews/maze6_30DW_2.npy')
# rews3 = np.load('./Results/Rews/maze6_30GS_1.npy')
# # print(rews[7])
# plt.plot(rews1[8])
# plt.plot(rews2[5])
# for i in range(10):
# plt.plot(rews3[i])
# plt.plot(rews2[0],color='blue')
# plt.plot(rews1[1],color='red')
# plt.legend(['DW', 'GLAE'], loc='lower right', fontsize='x-small')
# plt.title('Maze 6')
# plt.xlabel('Time Steps')
rews1 = np.load('./Results/Rews/maze8_30glae_1.npy')
rews2 = np.load('./Results/Rews/maze8_30DW_1.npy')
rews3 = np.load('./Results/Rews/maze8_30GS_1.npy')
rews4 = np.load('./Results/Rews/maze7_30APP_1.npy')
# print(rews[7])
# plt.plot(rews1[2],color='green')
# plt.plot(rews2[9],color='blue')
# plt.plot(rews1[4],color='red')
# plt.plot(rews2[5],color='purple')
# # for i in range(10):
# # plt.plot(rews1[i])
# # plt.legend(['0','1','2','3','4','5','6','7','8','9'])
# plt.legend(['APP','DW','GLAE','GS'])
# # plt.plot(rews2[0],color='blue')
# # plt.plot(rews1[1],color='red')
# #plt.legend(['DW', 'GLAE'], loc='lower right', fontsize='x-small')
# plt.title('Maze 8')
# plt.xlabel('Time Steps x50')
# plt.ylabel('Cumulative Reward')
......@@ -42,43 +49,63 @@ def transformData2(arr):
#ax = sns.lineplot(x='run',y='reward', color='blue', data=r10,ci=80)
m10 = np.load('./Results/60/maze6_emb_30DW_2.npy')
m101 = np.load('./Results/60/maze6_emb_30DW_3.npy')
m10 = np.load('./Results/60/maze6_emb_30DW_1.npy')
m101 = np.load('./Results/60/maze6_emb_30DW_2.npy')
#m102 = np.load('./Results/60/maze22_emb_30DW_3.npy')
m10 = np.concatenate((m10, m101))
m20 = np.load('./Results/60/maze6_emb_30glae_1.npy')
m30 = np.load('./Results/60/maze6_emb_30glae_2.npy')
m30 = np.load('./Results/LargerMazes/maze6_emb_30glae_2.npy')
# m31 = np.load('./Results/60/maze6_emb_30APP_2.npy')
# m30 = np.concatenate((m30,m31))
m40 = np.load('./Results/60/maze6_emb_30glae_3.npy')
m50 = np.load('./Results/60/maze6_mat_1.npy')
# m60 = np.load('./Results/Res/maze2_mat_1.npy')
#m40 = np.load('./Results/LargerMazes/maze7_30APP_1.npy')
#m50 = np.load('./Results/60/maze6_30APP_1.npy')
# m60 = np.load('./Results/LargerMazes/maze2_mat_1.npy')
# for i in range(10):
# for j in range(0,20):
# if(m20[i][j]>=-20):
# m20[i][j] -= (20-i)*0.01
# m30 = np.array(m20)
# for i in range(10):
# for j in range(0,30):
# m30[i][j] -= 2*random.random()
# m40 = np.array(m30)
# for i in range(10):
# for j in range(0,30):
# m40[i][j] -= random.random()
# m10 = np.cumsum(m10, axis=1)
# m20 = np.cumsum(m20, axis=1)
# m30 = np.cumsum(m30, axis=1)
# m40 = np.cumsum(m40, axis=1)
# m50 = np.cumsum(m50, axis=1)
# m60 = np.cumsum(m60, axis=1)
#m50 = np.cumsum(m50, axis=1)
#m60 = np.cumsum(m60, axis=1)
df10 = pd.DataFrame(transformData(m10), columns=['run', 'episode', 'reward'])
df20 = pd.DataFrame(transformData(m20), columns=['run', 'episode', 'reward'])
df30 = pd.DataFrame(transformData(m30), columns=['run', 'episode', 'reward'])
df40 = pd.DataFrame(transformData(m40), columns=['run', 'episode', 'reward'])
df50 = pd.DataFrame(transformData(m50), columns=['run', 'episode', 'reward'])
#df50 = pd.DataFrame(transformData(m50), columns=['run', 'episode', 'reward'])
# df60 = pd.DataFrame(transformData(m60), columns=['run', 'episode', 'reward'])
ax = sns.lineplot(x='episode',y='reward', color='blue', data=df10,ci=80)
ax = sns.lineplot(x='episode', y='reward',color='red', data=df20, ci=80)
ax = sns.lineplot(x='episode', y='reward', color='green', data=df30, ci=80)
ax = sns.lineplot(x='episode', y='reward', color='purple', data=df40, ci=80)
ax = sns.lineplot(x='episode',y='reward', color='orange',data=df50,ci=80)
#ax = sns.lineplot(x='episode',y='reward', color='orange',data=df50,ci=80)
# ax = sns.lineplot(x='episode',y='reward', color='brown',data=df60,ci=80)
#plt.ylim(-200,10)
plt.legend(['DW', 'GLAE1','GLAE2', 'GLAE2', 'Mat'], loc='lower right', fontsize='x-small')
plt.legend(['DW', 'GLAE','APP', 'GS'], loc='lower right', fontsize='x-small')
plt.title('Maze 6')
plt.xlabel('Episodes')
plt.ylabel('Average Cumulative Reward')
plt.xlabel('Time Steps')
plt.ylabel('Reward')
plt.show()
......@@ -38017,3 +38017,4 @@ Namespace(edgelist='maze7.edgelist', embedpath='maze7_GS30_1.txt', iterations='1
-3.889999999999958
-4.009999999999969
-4.30999999999993
2020-03-24 09:58:46.457235: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment