Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to evaluate if I get a checkpoint file? #46

Open
JiuqingDong opened this issue Jul 3, 2023 · 1 comment
Open

How to evaluate if I get a checkpoint file? #46

JiuqingDong opened this issue Jul 3, 2023 · 1 comment

Comments

@JiuqingDong
Copy link

Hi, could you tell me how can I evaluate the model when I finished the tuning?

@JiuqingDong
Copy link
Author

JiuqingDong commented Jul 12, 2023

Oh, I already solved this issue and forgot to put the solution here.

Step 1: Save the full model for best_metric.
if curr_acc >= best_metric:
model_state = self.model.state_dict()
out_path = os.path.join(self.cfg.OUTPUT_DIR, "best_model.pth")
torch.save(model_state, out_path)

Step 2: Train(Tuning) the model and get the checkpoint file. Besides,
Use 'model.load_state_dict(torch.load(cfg.MODEL.WEIGHT_PATH))' to load the checkpoint.

Step 3: Create a shell file like this:

python tune_fgvc.py
--train-type "prompt"
--config-file configs/prompt/cub.yaml
MODEL.TYPE "vit"
DATA.BATCH_SIZE "128"
MODEL.PROMPT.DEEP "True"
MODEL.PROMPT.DROPOUT "0.1"
MODEL.PROMPT.NUM_TOKENS "10"
DATA.FEATURE "sup_vitb16_imagenet21k"
MODEL.MODEL_ROOT "models/"
OUTPUT_DIR "./prompt_tuning/CUB/"
MODEL.WEIGHT_PATH "/Path/val_CUB_model.pth"
SOLVER.TOTAL_EPOCH '0' \

By the way, It is a naive way to do evaluation. I want to know how to use logits.pth to do the evaluation, because in your code, you just save the {"targets": total_targets, "joint_logits": joint_logits} in checkpoint file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant