Skip to content

AttributeError: 'Namespace' object has no attribute 'num_classes' / Missing and Unexpected keys in state_dict #2

@ge97qir

Description

@ge97qir

I assume I have all the correct dependencies since I had errors before and resolved them by installing cuda 9.0 with gcc-5 and g++-5, but now I can not seem to solve this issue.
When I run the evaluate.py script I get the following error:

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 37, in main
    model = get_model(num_classes=args.num_classes)
AttributeError: 'Namespace' object has no attribute 'num_classes'

If I change the num_classes to anything but 7 I get the following err (this example is without putting in a parameter):

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 41, in main
    model.load_state_dict(saved_state_dict, strict=False)
  File "/home/lukak/anaconda3/envs/CompositionalHumanParsing/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Stream:
	size mismatch for decoder.layer_dsn.3.weight: copying a param of torch.Size([20, 512, 1, 1]) from checkpoint, where the shape is torch.Size([7, 512, 1, 1]) in current model.
	size mismatch for decoder.layer_dsn.3.bias: copying a param of torch.Size([20]) from checkpoint, where the shape is torch.Size([7]) in current model.

When I change the num_classes to 7 I get the following err with long list of missing keys and unexpected keys:

Traceback (most recent call last):
  File "evaluate.py", line 234, in <module>
    main()
  File "evaluate.py", line 41, in main
    model.load_state_dict(saved_state_dict)
  File "/home/lukak/anaconda3/envs/CompositionalHumanParsing/lib/python3.6/site-packages/torch/nn/modules/module.py", line 719, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Stream:
	Missing key(s) in state_dict:  "decoder.layer5.b0.0.weight", "decoder.layer5.b0.1.weight", "decoder.layer5.b0.1.bias", ...
        .
        .
        .
        Unexpected key(s) in state_dict: "decoder.layer6.alpha", "decoder.layer6.conv0.0.weight", "decoder.layer6.conv0.1.weight", ...
        .
        .
        .

I have searched the internet for answers but found nothing that helped and as I am not an experienced software engineer any help would be appreciated.

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