I was trying to make DDPG_critic's neural network layer with code,
def get_critic():
#num_states = 8 ; num_actions = 2
state_input = Input(shape=(num_states,),name='critic_state_input_layer')
state_out = Dense(32, activation="relu",name='critic_state_output_layer')(state_input)
action_input = Input(shape=(num_actions,),name='critic_action_input_layer')
action_out = Dense(32,activation="relu",name='critic_action_output_layer')(action_input)
concat = layers.Concatenate(axis=-1)([state_out, action_out])
out3 = Dense(256, activation="relu",name='critic_out3_layer')(concat)
out4 = Dense(256, activation="relu",name='critic_out4_layer')(out3)
outputs = Dense(1,name='critic_output_layer')(out4)
model = Model([state_input, action_input], outputs,name='critic_model')
And I got problem about
ValueError: Exception encountered when calling layer "critic_model" (type Functional).
Input 0 of layer "critic_action_output_layer" is incompatible with the layer: expected axis -1of input shape to have value 2, but received input with shape (64, 1)
It would be thankful if you point out the problem and how to solve it!
Model architecture has no issue. Check your input data shape
import tensorflow as tf
state_input = tf.keras.Input(shape=(8,),name='critic_state_input_layer')
state_out = tf.keras.layers.Dense(32, activation="relu",name='critic_state_output_layer')(state_input)
state_out.shape
Output
TensorShape([None, 32])
Second layer
action_input = tf.keras.Input(shape=(2,),name='critic_action_input_layer')
action_out = tf.keras.layers.Dense(32,activation="relu",name='critic_action_output_layer')(action_input)
action_out.shape
Output
TensorShape([None, 32])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.