usail-hkust / LLMTSCS

Official code for article "LLMLight: Large Language Models as Traffic Signal Control Agents".
139 stars 12 forks source link

Different RL Model Shape on Transferability #20

Open DA21S321D opened 1 month ago

DA21S321D commented 1 month ago

When i use the model trained on map jinan 1 anon_3_4_jinan_real.json to do transferability test on map hangzhou 1 anon_4_4_hangzhou_real.json shown in your paper 图片 i met this problem: 图片

DA21S321D commented 1 month ago

图片 Also, the RL method shape is different, how can i run it on NewYork map?

Gungnir2099 commented 1 month ago

Please try this function:

    def build_network_from_copy_only_weight(self, network, network_copy):
        """Initialize a Q network from a copy"""
        network_weights = network_copy.get_weights()
        network.set_weights(network_weights)
        network.compile(optimizer=Adam(lr=self.dic_agent_conf["LEARNING_RATE"]),
                        loss=self.dic_agent_conf["LOSS_FUNCTION"])
        return network
DA21S321D commented 1 month ago

Thanks, with your help i successfully load model trained on jinan and then deploy it on newyork map. Advancedcolight, EfficientColight and Colight are fine, but MPlight seems to be different. How can i make jinan model trained by MPlight run on newyork map? 图片

DA21S321D commented 1 month ago

This is the error, i have no idea how to handle this: 图片

Gungnir2099 commented 1 month ago

MPLight can be directly loaded by load_network(*), a function from ./models/network_agent.py.

    def load_network(self, file_name, file_path=None):
        if file_path is None:
            file_path = self.dic_path["PATH_TO_MODEL"]
        self.q_network = load_model(os.path.join(file_path, "%s.h5" % file_name), custom_objects={"Selector": Selector})
        print("succeed in loading model %s" % file_name)
DA21S321D commented 1 month ago

I modified the path of the pretrained MPlight model in this line (modified here) to load the network. And then i run the run_mplight like this:python run_mplight.py--dataset newyork_28x7 --traffic_file anon_28_7_newyork_real_double.json --proj_name Scalability. And when this script run into model_test. It occurs this problem again: 图片 Am i doing wrong in some percedure?

Gungnir2099 commented 1 month ago

Sorry, I haven't encountered your problem before. You may need to use the debug mode to locate the exact problem.