Tensorflow:两次加载相同模型时出现的问题

时间:2019-12-26 02:34:28

标签: python tensorflow machine-learning deep-learning tensorflow2.0

我训练了我的张量流模型并保存了它。 为了进行评估,我加载了两个训练有素的模型并执行了它们。 在这里,我遇到了一个奇怪的问题。

    graph1 = tf.Graph()
    graph1.as_default()
    sess1 = tf.Session()
    agent_0 = DeepCFR(
        sess1, env,
        policy_network_layers,
        advantage_network_layers)

    saver1 = tf.train.import_meta_graph(model_path + "excute-4700.meta")
    saver1.restore(sess1, model_path + "excute-4700")

    graph2 = tf.Graph()
    graph2.as_default()
    sess2 = tf.Session()
    agent_1 = DeepCFR(
        sess2, env,
        policy_network_layers,
        advantage_network_layers)

    saver2 = tf.train.import_meta_graph(model_path + "excute-4700.meta")
    saver2.restore(sess2, model_path + "excute-4700")

我尝试将一个训练好的模型加载到两个图中,如您所见。但是,这两个加载的代理对相同的输入值返回了不同的输出。

screen capture in runtime to check the output of both agents

这是怎么了?我认为这两个模型的权重有所不同,原因是我无法理解一些未知的原因。

现在,我不确定加载训练的模型是否与保存的模型相同。

请让我知道我的代码出了什么问题。

谢谢。

0 个答案:

没有答案
相关问题