models/moa_model.py
def forward(self, input_dict, state, seq_lens):
        """
        First evaluate non-LSTM parts of model. Then add a time dimension to the batch before
        sending inputs to forward_rnn(), which evaluates the LSTM parts of the model.
        :param input_dict: The input tensors.
        :param state: The model state.
        :param seq_lens: LSTM sequence lengths.
        :return: The agent's own action logits and the new model state.
        """
        # Evaluate non-lstm layers
        actor_critic_fc_output, moa_fc_output = self.moa_encoder_model(input_dict["obs"]["curr_obs"])

        rnn_input_dict = {
            "ac_trunk": actor_critic_fc_output,
            "prev_moa_trunk": state[5],
            "other_agent_actions": input_dict["obs"]["other_agent_actions"],
            "visible_agents": input_dict["obs"]["visible_agents"],
            "prev_actions": input_dict["prev_actions"],
        }

        # Add time dimension to rnn inputs
        for k, v in rnn_input_dict.items():
            rnn_input_dict[k] = add_time_dimension(v, seq_lens)

        output, new_state = self.forward_rnn(rnn_input_dict, state, seq_lens)
        action_logits = tf.reshape(output, [-1, self.num_outputs])
        counterfactuals = tf.reshape(
            self._counterfactuals,
            [-1, self._counterfactuals.shape[-2], self._counterfactuals.shape[-1]],
        )
        new_state.extend([action_logits, moa_fc_output])

        self.compute_influence_reward(input_dict, state[4], counterfactuals)

        return action_logits, new_state

        First evaluate non-LSTM parts of model. Then add a time dimension to the batch before
        sending inputs to forward_rnn(), which evaluates the LSTM parts of the model.
        :param input_dict: The input tensors.
        :param state: The model state.
        :param seq_lens: LSTM sequence lengths.
        :return: The agent's own action logits and the new model state.
        
First evaluate non-LSTM parts of model. Then add a time dimension to the batch before
sending inputs to forward_rnn(), which evaluates the LSTM parts of the model.
First evaluate non - LSTM parts of model . Then add a time dimension to the batch before sending inputs to forward_rnn () which evaluates the LSTM parts of the model .
def forward(self, input_dict, state, seq_lens):
        actor_critic_fc_output, moa_fc_output = self.moa_encoder_model(input_dict["obs"]["curr_obs"])
        rnn_input_dict = {
            "ac_trunk": actor_critic_fc_output,
            "prev_moa_trunk": state[5],
            "other_agent_actions": input_dict["obs"]["other_agent_actions"],
            "visible_agents": input_dict["obs"]["visible_agents"],
            "prev_actions": input_dict["prev_actions"],
        }
        for k, v in rnn_input_dict.items():
            rnn_input_dict[k] = add_time_dimension(v, seq_lens)
        output, new_state = self.forward_rnn(rnn_input_dict, state, seq_lens)
        action_logits = tf.reshape(output, [-1, self.num_outputs])
        counterfactuals = tf.reshape(
            self._counterfactuals,
            [-1, self._counterfactuals.shape[-2], self._counterfactuals.shape[-1]],
        )
        new_state.extend([action_logits, moa_fc_output])
        self.compute_influence_reward(input_dict, state[4], counterfactuals)
        return action_logits, new_state
def forward ( self , input_dict , state , seq_lens ) : actor_critic_fc_output , moa_fc_output = self . moa_encoder_model ( input_dict [ "obs" ] [ "curr_obs" ] ) rnn_input_dict = { "ac_trunk" : actor_critic_fc_output , "prev_moa_trunk" : state [ 5 ] , "other_agent_actions" : input_dict [ "obs" ] [ "other_agent_actions" ] , "visible_agents" : input_dict [ "obs" ] [ "visible_agents" ] , "prev_actions" : input_dict [ "prev_actions" ] , } for k , v in rnn_input_dict . items ( ) : rnn_input_dict [ k ] = add_time_dimension ( v , seq_lens ) output , new_state = self . forward_rnn ( rnn_input_dict , state , seq_lens ) action_logits = tf . reshape ( output , [ - 1 , self . num_outputs ] ) counterfactuals = tf . reshape ( self . _counterfactuals , [ - 1 , self . _counterfactuals . shape [ - 2 ] , self . _counterfactuals . shape [ - 1 ] ] , ) new_state . extend ( [ action_logits , moa_fc_output ] ) self . compute_influence_reward ( input_dict , state [ 4 ] , counterfactuals ) return action_logits , new_state
First evaluate non-LSTM parts of model.
First evaluate non - LSTM parts of model .
"""
        First evaluate non-LSTM parts of model. Then add a time dimension to the batch before
        sending inputs to forward_rnn(), which evaluates the LSTM parts of the model.
        :param input_dict: The input tensors.
        :param state: The model state.
        :param seq_lens: LSTM sequence lengths.
        :return: The agent's own action logits and the new model state.
        """ # Evaluate non-lstm layers # Add time dimension to rnn inputs
The agent's own action logits and the new model state.
The agent ' s own action logits and the new model state .
self
input_dict
The input tensors.
The input tensors .
state
The model state.
The model state .
seq_lens
LSTM sequence lengths.
LSTM sequence lengths .