Esempio n. 1
0
 def export_model(self, name_behavior_id: str) -> None:
     """
     Exports the model
     """
     policy = self.get_policy(name_behavior_id)
     settings = SerializationSettings(policy.model_path, policy.brain.brain_name)
     export_policy_model(settings, policy.graph, policy.sess)
Esempio n. 2
0
    def save(self, output_filepath: str, settings: SerializationSettings) -> None:
        """
        Saves the serialized model, given a path and SerializationSettings

        This method will save the policy graph to the given filepath.  The path
        should be provided without an extension as multiple serialized model formats
        may be generated as a result.

        :param output_filepath: path (without suffix) for the model file(s)
        :param settings: SerializationSettings for how to save the model.
        """
        export_policy_model(output_filepath, settings, self.graph, self.sess)
def test_policy_conversion(dummy_config, tmpdir, rnn, visual, discrete):
    tf.reset_default_graph()
    dummy_config["output_path"] = os.path.join(tmpdir, "test")
    policy = create_policy_mock(dummy_config,
                                use_rnn=rnn,
                                use_discrete=discrete,
                                use_visual=visual)
    policy.save_model(1000)
    settings = SerializationSettings(
        policy.model_path, os.path.join(tmpdir, policy.brain.brain_name))
    export_policy_model(settings, policy.graph, policy.sess)

    # These checks taken from test_barracuda_converter
    assert os.path.isfile(os.path.join(tmpdir, "test.nn"))
    assert os.path.getsize(os.path.join(tmpdir, "test.nn")) > 100