Closed wahaha-1 closed 3 months ago
Check config["LPACModel"]["Model"] and make sure your config file has the path to the state dictionary. It seems you are loading a model and not a state dictionary.
I am using the default configuration and only changed the model files in the configuration file. The problem I found is: when loading the model, a model instance is passed instead of a state dictionary. torch.load should load a state dictionary containing model parameters, but the code is passed an instance of the LPAC class learning_params.toml:
[LPACModel]
Dir = "${CoverageControl_ws}/lpac/models/"
Model = "modelK1.pt"
Optimizer = "optimizerK1.pt"
[CNNModel]
Dir = "${CoverageControl_ws}/lpac/models/" # Absolute location
Model = "modelK1.pt"
Optimizer = "optimizerK1.pt"
[ModelConfig]
UseCommMaps = true
eval.toml:
[[Controllers]]
Name = "lpac"
Type = "Learning"
# ModelFile: "~/CoverageControl_ws/datsets/lpac/models/model_k3_1024.pt"
#ModelStateDict = "${CoverageControl_ws}/lpac/models/model_k3_1024_state_dict.pt"
ModelStateDict = "${CoverageControl_ws}/lpac/models/modelK1_epoch10.pt"
LearningParams = "${CoverageControl_ws}/lpac/params/learning_params.toml"
UseCommMap = true
UseCNN = true
CNNMapSize = 32
I just modified it and it worked successfully. But I don’t quite understand why your model suffix is _state_dict.pt eval.toml:
Name = "lpac"
Type = "Learning"
# ModelFile: "~/CoverageControl_ws/datsets/lpac/models/model_k3_1024.pt"
ModelFile ="~/CoverageControl_ws/lpac/models/modelK1_epoch10.pt"
#ModelStateDict = "${CoverageControl_ws}/lpac/models/model_k3_1024_state_dict.pt"
#ModelStateDict = "${CoverageControl_ws}/lpac/models/modelK1_epoch10.pt"
LearningParams = "${CoverageControl_ws}/lpac/params/learning_params.toml"
UseCommMap = true
I encountered an issue when trying to generate and use a model instance after training according to the LPAC network. After training, a model instance is generated, but the reference model provided is a dictionary containing model parameters. I attempted to modify the code to generate the same file type, but it still didn't work.
Below are the details of the modification method I used and the resulting error code.
Error Message:
Modified Training Script (
train_lpac.py
):Modified Loading Script (
eval.py
):But it doesn't work