Skip to content

预测出错 #6

@lkcode1314

Description

@lkcode1314

魔导,预测时候的label_path [是干啥的,权重文件路径怎么没有,一直预测错误。
RuntimeError: Error(s) in loading state_dict for ResNet:
Unexpected key(s) in state_dict: "total_ops", "total_params", "layer1.0.total_ops", "layer1.0.total_params", "layer1.1.total_ops", "layer1.1.total_params", "layer1.2.total_ops", "layer1.2.total_params", "layer2.0.total_ops", "layer2.0.total_params", "layer2.1.total_ops", "layer2.1.total_params", "layer2.2.total_ops", "layer2.2.total_params", "layer2.3.total_ops", "layer2.3.total_params", "layer3.0.total_ops", "layer3.0.total_params", "layer3.1.total_ops", "layer3.1.total_params", "layer3.2.total_ops", "layer3.2.total_params", "layer3.3.total_ops", "layer3.3.total_params", "layer3.4.total_ops", "layer3.4.total_params", "layer3.5.total_ops", "layer3.5.total_params", "layer4.0.total_ops", "layer4.0.total_params", "layer4.1.total_ops", "layer4.1.total_params", "layer4.2.total_ops", "layer4.2.total_params".
size mismatch for fc.1.weight: copying a param with shape torch.Size([5, 2048]) from checkpoint, the shape in current model is torch.Size([3674, 2048]).
size mismatch for fc.1.bias: copying a param with shape torch.Size([5]) from checkpoint, the shape in current model is torch.Size([3674]).

parser = argparse.ArgumentParser()
parser.add_argument('--model_name', type=str, default='resnet50', help='model name')
parser.add_argument('--pretrained', action="store_false", help='using pretrain weight')
parser.add_argument('--weight', type=str, default='', help='loading weight path')
parser.add_argument('--config', type=str, default='config/config.py', help='config path')
parser.add_argument('--device', type=str, default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')

parser.add_argument('--train_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\train', help='train data path')
parser.add_argument('--val_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\val', help='val data path')
parser.add_argument('--test_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\test', help='test data path')
parser.add_argument('--label_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\flower_photos\label.txt', help='label path')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions