Skip to content

t() expects a tensor with <= 2 dimensions, but self is 4D #3

@haidongwang3629

Description

@haidongwang3629

Thanks for the awosome sharing! Really appearate this work!

While run the testing scripts: python3 test.py --config configs/test.yaml (i have already trained APINet )

experiment: name: test_APINet cuda: [0] dataset: name: cub root_dir: data/bird/CUB_200_2011/images meta_dir: metadata/cub batch_size: 32 num_workers: 4 transformer: resize_size: 448 image_size: 448 model: name: APINet num_classes: 200 load: results/APINet/API_res101_1/best_model.pth

it reports the following message:

Traceback (most recent call last): File "/home/haidongwang/code/Hawkeye/test.py", line 147, in <module> tester.test() File "/home/haidongwang/code/Hawkeye/test.py", line 119, in test self.validate() File "/home/haidongwang/code/Hawkeye/test.py", line 129, in validate self.batch_validate(data) File "/home/haidongwang/code/Hawkeye/test.py", line 135, in batch_validate logits = self.model(images) File "/home/haidongwang/anaconda3/envs/chenli/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/home/haidongwang/code/Hawkeye/model/methods/APINet.py", line 34, in forward intra_pairs, inter_pairs, intra_labels, inter_labels = self.get_pairs(pool_out, targets) File "/home/haidongwang/code/Hawkeye/model/methods/APINet.py", line 77, in get_pairs distance_matrix = pdist(embeddings).detach().cpu().numpy() File "/home/haidongwang/code/Hawkeye/model/methods/APINet.py", line 117, in pdist distance_matrix = -2 * vectors.mm(torch.t(vectors)) + vectors.pow(2).sum(dim=1).view(1, -1) \ **RuntimeError: t() expects a tensor with <= 2 dimensions, but self is 4D**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions