ValueError: Переменная adv_agent / adv_agent / pMA_func / action_cell / action / agentAction_1 / полностью подключена / weights / Adam / не существует - PullRequest
0 голосов
/ 11 октября 2019

Когда я запускаю код, произошла следующая ошибка. '' 'ValueError: Переменная adv_agent / adv_agent / pMA_func / action_cell / action / agentAction_1 / полностью_связанная / weights / Adam / не существует или не была создана с помощью tf.get_variable (). Вы хотели установить reuse = tf.AUTO_REUSE в VarScope? '' 'Я обнаружил, что adv_agent / adv_agent не является правильным, потому что я установил только один adv_agent для variable_scope. Я изменяю только следующий код

'' 'def action (self, input_encode, input_com, num_outputs = 0, scope =' action ', reuse = False): с помощью tf.variable_scope (scope, reuse = reuse): input_encode = input_encode [self.p_index] input_com = input_com [:, self.p_index * self.nunits: (self.p_index + 1) * self.nunits] input = tf.concat ([input_encode, input_com], axis = 1) out = Layers.ful_connected (входные данные, num_outputs = arglist.action_units, активации_fn = tf.nn.relu)'' '

к этому коду.

' '' def действие (self, input_encode, input_com, num_outputs = 0, scope = 'action', повторное использование = False): с tf.variable_scope(область действия, повторное использование = повторное использование): input_encode = input_encode [self.p_index] input_com = controls_com [:, self.p_index * self.nunits: (self.p_index + 1) * self.nunits]
input = tf.concat([input_encode, input_com], axis = 1) out = layer.fully_connected (input, num_outputs = arglist.action_units,activ_fn = tf.nn.relu) out = Layers.ful_connected (out, num_outputs = num_outputs, Activation_FN = None) return out

def actor_model(self, input, num_outputs, scope, reuse=False):
    with tf.variable_scope(scope, reuse=reuse):
        with tf.variable_scope(name_or_scope='encode_com_cell', reuse=reuse):  
            agents_obs_encode = self.agents_encoder(input, scope="encoder", reuse=reuse)
            agents_com_info = self.comm_fc(agents_obs_encode, scope="comm_unit", reuse=reuse)  
        with tf.variable_scope(name_or_scope='action_cell', reuse=reuse): 设置scope为agent_i.
            output = self.action(agents_obs_encode, agents_com_info, num_outputs, scope="action", reuse=reuse)
        return output

'' '

...