models/moa_model.py
def create_moa_encoder_model(obs_space, model_config):
        """
        Creates the convolutional part of the MOA model.
        Also casts the input uint8 observations to float32 and normalizes them to the range [0,1].
        :param obs_space: The agent's observation space.
        :param model_config: The config dict containing parameters for the convolution type/shape.
        :return: A new Model object containing the convolution.
        """
        original_obs_dims = obs_space.original_space.spaces["curr_obs"].shape
        inputs = tf.keras.layers.Input(original_obs_dims, name="observations", dtype=tf.uint8)

        # Divide by 255 to transform [0,255] uint8 rgb pixel values to [0,1] float32.
        last_layer = tf.keras.backend.cast(inputs, tf.float32)
        last_layer = tf.math.divide(last_layer, 255.0)

        # Build the CNN layer
        conv_out = build_conv_layers(model_config, last_layer)

        # Build Actor-critic FC layers
        actor_critic_fc = build_fc_layers(model_config, conv_out, "policy")

        # Build MOA layers
        moa_fc = build_fc_layers(model_config, conv_out, "moa")

        return tf.keras.Model(inputs, [actor_critic_fc, moa_fc], name="MOA_Encoder_Model")

        Creates the convolutional part of the MOA model.
        Also casts the input uint8 observations to float32 and normalizes them to the range [0,1].
        :param obs_space: The agent's observation space.
        :param model_config: The config dict containing parameters for the convolution type/shape.
        :return: A new Model object containing the convolution.
        
Creates the convolutional part of the MOA model.
Also casts the input uint8 observations to float32 and normalizes them to the range [0,1].
Creates the convolutional part of the MOA model . Also casts the input uint8 observations to float32 and normalizes them to the range [ 0 1 ] .
def create_moa_encoder_model(obs_space, model_config):
        original_obs_dims = obs_space.original_space.spaces["curr_obs"].shape
        inputs = tf.keras.layers.Input(original_obs_dims, name="observations", dtype=tf.uint8)
        last_layer = tf.keras.backend.cast(inputs, tf.float32)
        last_layer = tf.math.divide(last_layer, 255.0)
        conv_out = build_conv_layers(model_config, last_layer)
        actor_critic_fc = build_fc_layers(model_config, conv_out, "policy")
        moa_fc = build_fc_layers(model_config, conv_out, "moa")
        return tf.keras.Model(inputs, [actor_critic_fc, moa_fc], name="MOA_Encoder_Model")
def create_moa_encoder_model ( obs_space , model_config ) : original_obs_dims = obs_space . original_space . spaces [ "curr_obs" ] . shape inputs = tf . keras . layers . Input ( original_obs_dims , name = "observations" , dtype = tf . uint8 ) last_layer = tf . keras . backend . cast ( inputs , tf . float32 ) last_layer = tf . math . divide ( last_layer , 255.0 ) conv_out = build_conv_layers ( model_config , last_layer ) actor_critic_fc = build_fc_layers ( model_config , conv_out , "policy" ) moa_fc = build_fc_layers ( model_config , conv_out , "moa" ) return tf . keras . Model ( inputs , [ actor_critic_fc , moa_fc ] , name = "MOA_Encoder_Model" )
Creates the convolutional part of the MOA model.
Creates the convolutional part of the MOA model .
"""
        Creates the convolutional part of the MOA model.
        Also casts the input uint8 observations to float32 and normalizes them to the range [0,1].
        :param obs_space: The agent's observation space.
        :param model_config: The config dict containing parameters for the convolution type/shape.
        :return: A new Model object containing the convolution.
        """ # Divide by 255 to transform [0,255] uint8 rgb pixel values to [0,1] float32. # Build the CNN layer # Build Actor-critic FC layers # Build MOA layers
A new Model object containing the convolution.
A new Model object containing the convolution .
obs_space
The agent's observation space.
The agent ' s observation space .
model_config
The config dict containing parameters for the convolution type/shape.
The config dict containing parameters for the convolution type / shape .