models/scm_model.py
def create_scm_encoder_model(obs_space, model_config):
        """
        Create the encoder submodel, which is part of the SCM.
        :param obs_space: A single agent's observation space.
        :param model_config: The model config dict.
        :return: A new encoder model.
        """
        original_obs_dims = obs_space.original_space.spaces["curr_obs"].shape
        input_layer = 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(input_layer, tf.float32)
        last_layer = tf.math.divide(last_layer, 255.0)

        activation = get_activation_fn(model_config.get("conv_activation"))
        filters = model_config.get("conv_filters")
        out_size, kernel, stride = filters[-1]
        conv_out = tf.keras.layers.Conv2D(
            out_size,
            kernel,
            strides=(stride, stride),
            activation=activation,
            padding="valid",
            name="conv_scm_encoder",
        )(last_layer)
        flattened_conv_out = tf.keras.layers.Flatten()(conv_out)

        return tf.keras.Model(input_layer, flattened_conv_out, name="SCM_Encoder_Model")

        Create the encoder submodel, which is part of the SCM.
        :param obs_space: A single agent's observation space.
        :param model_config: The model config dict.
        :return: A new encoder model.
        
Create the encoder submodel, which is part of the SCM.
Create the encoder submodel which is part of the SCM .
def create_scm_encoder_model(obs_space, model_config):
        original_obs_dims = obs_space.original_space.spaces["curr_obs"].shape
        input_layer = tf.keras.layers.Input(original_obs_dims, name="observations", dtype=tf.uint8)
        last_layer = tf.keras.backend.cast(input_layer, tf.float32)
        last_layer = tf.math.divide(last_layer, 255.0)
        activation = get_activation_fn(model_config.get("conv_activation"))
        filters = model_config.get("conv_filters")
        out_size, kernel, stride = filters[-1]
        conv_out = tf.keras.layers.Conv2D(
            out_size,
            kernel,
            strides=(stride, stride),
            activation=activation,
            padding="valid",
            name="conv_scm_encoder",
        )(last_layer)
        flattened_conv_out = tf.keras.layers.Flatten()(conv_out)
        return tf.keras.Model(input_layer, flattened_conv_out, name="SCM_Encoder_Model")
def create_scm_encoder_model ( obs_space , model_config ) : original_obs_dims = obs_space . original_space . spaces [ "curr_obs" ] . shape input_layer = tf . keras . layers . Input ( original_obs_dims , name = "observations" , dtype = tf . uint8 ) last_layer = tf . keras . backend . cast ( input_layer , tf . float32 ) last_layer = tf . math . divide ( last_layer , 255.0 ) activation = get_activation_fn ( model_config . get ( "conv_activation" ) ) filters = model_config . get ( "conv_filters" ) out_size , kernel , stride = filters [ - 1 ] conv_out = tf . keras . layers . Conv2D ( out_size , kernel , strides = ( stride , stride ) , activation = activation , padding = "valid" , name = "conv_scm_encoder" , ) ( last_layer ) flattened_conv_out = tf . keras . layers . Flatten ( ) ( conv_out ) return tf . keras . Model ( input_layer , flattened_conv_out , name = "SCM_Encoder_Model" )
Create the encoder submodel, which is part of the SCM.
Create the encoder submodel which is part of the SCM .
"""
        Create the encoder submodel, which is part of the SCM.
        :param obs_space: A single agent's observation space.
        :param model_config: The model config dict.
        :return: A new encoder model.
        """ # Divide by 255 to transform [0,255] uint8 rgb pixel values to [0,1] float32.
A new encoder model.
A new encoder model .
obs_space
A single agent's observation space.
A single agent ' s observation space .
model_config
The model config dict.
The model config dict .