Пример #1
0
 def load_model(self, model_table_name, model_namespace):
     LOGGER.info("@ load guest model from name/ns" + ", " + str(model_table_name) + ", " + str(model_namespace))
     lr_model_name = model_table_name + "_lr_model"
     local_model_name = model_table_name + "_local_model"
     super(HeteroDNNLRHost, self).load_model(lr_model_name, model_namespace)
     model_parameters = load_model_parameters(local_model_name, model_namespace)
     self.local_model.restore_model(model_parameters)
Пример #2
0
    def test_save_n_load_model_parameters(self):
        model_parameters = {"Wh": np.array([[1, 2, 3, 4],
                                            [5, 6, 7, 8],
                                            [9, 10, 11, 12]]),
                            "bh": np.array([1, 1, 1, 1]),
                            "Wo": np.array([[1, 2, 3, 4],
                                            [5, 6, 7, 8],
                                            [9, 10, 11, 12]]),
                            "bo": np.array([0, 0, 0, 0]),
                            "model_meta": {"learning_rate": 0.01,
                                           "input_dim": 100,
                                           "hidden_dim": 64}
                            }
        model_table_name = "table_name_" + str(uuid.uuid1())
        model_table_ns = "table_ns_" + str(uuid.uuid1())
        save_model_parameters(model_parameters, model_table_name, model_table_ns)

        actual_model_parameters = load_model_parameters(model_table_name, model_table_ns)

        assert len(model_parameters) == len(actual_model_parameters)
        for k in actual_model_parameters.keys():
            if k == "model_meta":
                print(actual_model_parameters[k])
            else:
                assert_matrix(actual_model_parameters[k], model_parameters[k])
Пример #3
0
 def load_model(self, model_table_name, model_namespace):
     LOGGER.info("@ load host model from name/ns" + ", " +
                 str(model_table_name) + ", " + str(model_namespace))
     model_parameters = load_model_parameters(model_table_name,
                                              model_namespace)
     self.host_model.restore_model(model_parameters)