Skip to content

Commit

Permalink
Update - 12_12_2023
Browse files Browse the repository at this point in the history
  • Loading branch information
elisaalboni committed Dec 12, 2023
1 parent 9b88948 commit b6b3477
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 946 deletions.
41 changes: 4 additions & 37 deletions NeuralNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,7 @@ def __init__(self, env, conf, w_S=0):

def create_actor(self):
''' Create actor NN '''
if (self.conf.system_id == 'car' or self.conf.system_id == 'car_park') and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+1
elif self.conf.system_id == 'manipulator' and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+3
else:
nb_state_input = self.conf.nb_state

inputs = layers.Input(shape=(nb_state_input,))
inputs = layers.Input(shape=(self.conf.nb_state,))

lay1 = layers.Dense(self.conf.NH1,kernel_regularizer=regularizers.l1_l2(self.conf.kreg_l1_A,self.conf.kreg_l2_A),bias_regularizer=regularizers.l1_l2(self.conf.breg_l1_A,self.conf.breg_l2_A))(inputs)
leakyrelu1 = layers.LeakyReLU()(lay1)
Expand All @@ -71,14 +64,7 @@ def create_actor(self):

def create_critic_elu(self):
''' Create critic NN - elu'''
if (self.conf.system_id == 'car' or self.conf.system_id == 'car_park') and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+1
elif self.conf.system_id == 'manipulator' and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+3
else:
nb_state_input = self.conf.nb_state

state_input = layers.Input(shape=(nb_state_input,))
state_input = layers.Input(shape=(self.conf.nb_state,))

state_out1 = layers.Dense(16, activation='elu')(state_input)
state_out2 = layers.Dense(32, activation='elu')(state_out1)
Expand All @@ -93,14 +79,7 @@ def create_critic_elu(self):

def create_critic_sine_elu(self):
''' Create critic NN - elu'''
if (self.conf.system_id == 'car' or self.conf.system_id == 'car_park') and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+1
elif self.conf.system_id == 'manipulator' and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+3
else:
nb_state_input = self.conf.nb_state

state_input = layers.Input(shape=(nb_state_input,))
state_input = layers.Input(shape=(self.conf.nb_state,))

state_out1 = SinusodialRepresentationDense(64, activation='sine')(state_input)
state_out2 = layers.Dense(64, activation='elu')(state_out1)
Expand All @@ -115,14 +94,7 @@ def create_critic_sine_elu(self):

def create_critic_sine(self):
''' Create critic NN - elu'''
if (self.conf.system_id == 'car' or self.conf.system_id == 'car_park') and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+1
elif self.conf.system_id == 'manipulator' and self.conf.remap_angle:
nb_state_input = self.conf.nb_state+3
else:
nb_state_input = self.conf.nb_state

state_input = layers.Input(shape=(nb_state_input,))
state_input = layers.Input(shape=(self.conf.nb_state,))

state_out1 = SinusodialRepresentationDense(64, activation='sine')(state_input)
state_out2 = SinusodialRepresentationDense(64, activation='sine')(state_out1)
Expand Down Expand Up @@ -163,11 +135,6 @@ def eval(self, NN, input):
if self.conf.NORMALIZE_INPUTS:
input = normalize_tensor(input, self.conf.state_norm_arr)

if (self.conf.system_id == 'car' or self.conf.system_id == 'car_park') and self.conf.remap_angle:
input = tf.stack([input[:,0],input[:,1],tf.cos(input[:,2]),tf.sin(input[:,2]),input[:,3],input[:,4],input[:,5]], axis=1)
elif self.conf.system_id == 'manipulator' and self.conf.remap_angle:
input = tf.stack([tf.cos(input[:,0]),tf.sin(input[:,0]),tf.cos(input[:,1]),tf.sin(input[:,1]),tf.cos(input[:,2]),tf.sin(input[:,2]),input[:,3],input[:,4],input[:,5],input[:,6]], axis=1)

return NN(input, training=True)

def custom_logarithm(self,input):
Expand Down
Loading

0 comments on commit b6b3477

Please sign in to comment.