Skip to content

Commit

Permalink
Fixed Sigmoid Overflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
wert23239 committed Aug 22, 2017
1 parent f16ee42 commit 3058635
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def do_action(SQL,frame_count):
f_dict={mainQN.used_genomes:UsedGenomes,mainQN.genomes:Genomes,\
mainQN.imageIn:[new_screen],mainQN.condition:0,mainQN.correct_action:[10],mainQN.correct_mean:[10]}
#Gain Action from Tenserflow
a,before = sess.run([mainQN.predict,mainQN.Smooth],feed_dict=f_dict)
a,value,out = sess.run([mainQN.predict,mainQN.Value,mainQN.Qout],feed_dict=f_dict)
if(a==0):
print(a)
print(value)
print(out)
#a = np.random.choice(a_dist,p=a_dist)
#a = np.argmax([a_dist] == a)
#print(a)
Expand Down Expand Up @@ -189,7 +193,7 @@ def do_action(SQL,frame_count):
mainQN.imageIn:states,mainQN.condition:1,
mainQN.correct_action:trainBatch[:,1],mainQN.correct_mean:np.hstack(mean_list),
mainQN.targetQ:targetQ}
_,loss =sess.run([mainQN.updateModel,mainQN.loss], \
_,loss,Qs =sess.run([mainQN.updateModel,mainQN.loss,mainQN.Qout], \
feed_dict=final_dict)
updateTarget(targetOps,sess)
print("Epoch " + str(epoch) + " Complete")
Expand Down
2 changes: 1 addition & 1 deletion lib/SQL.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def GatherGenomes(self):
IndividualGenome.append([int(x) for x in content.split()])

Genomes.append(IndividualGenome) # Pad Last Genome
Genomes=pad_sequences(Genomes,maxlen=30,padding='post') # Allows RNN to Interpet Dynamic Sequence Length
Genomes=pad_sequences(Genomes,maxlen=300,padding='post') # Allows RNN to Interpet Dynamic Sequence Length
return Genomes
def exit(self):
self.cur.close()
Expand Down
4 changes: 2 additions & 2 deletions lib/reinforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def updateTarget(op_holder,sess):

class Qnetwork():
def __init__(self,h_size,s_size,POPULATION,BATCH,myScope):
self.genomes= tf.placeholder(shape=[POPULATION,30,3],dtype=tf.int32)
self.genomes= tf.placeholder(shape=[POPULATION,300,3],dtype=tf.int32)
self.condition = tf.placeholder(tf.int32, shape=[], name="condition")
self.correct_action=tf.placeholder(shape=[None], dtype=tf.int32)
self.correct_mean=tf.placeholder(shape=[None], dtype=tf.float32)
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(self,h_size,s_size,POPULATION,BATCH,myScope):
#hidden_rnn=tf.cond(self.condition < 1, lambda: hidden_rnn,lambda: tf.gather(hidden_rnn,self.action_holder))
self.hidden_combined= slim.fully_connected(combined,h_size,biases_initializer=None,activation_fn=tf.nn.relu)
self.hidden_combined_2= slim.fully_connected(self.hidden_combined,h_size//4,biases_initializer=None,activation_fn=tf.nn.relu)
self.regression= slim.fully_connected(self.hidden_combined_2,1,biases_initializer=None,activation_fn=tf.nn.tanh)
self.regression= slim.fully_connected(self.hidden_combined_2,1,biases_initializer=None,activation_fn=None)
self.Advantage=tf.cond(self.condition < 1,
lambda: tf.reshape(self.regression,[1,POPULATION]),
lambda: tf.reshape(self.regression,[1,BATCH])[0])
Expand Down

0 comments on commit 3058635

Please sign in to comment.