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

Calculate the ACC error during train the model #206

Closed
VivizSun opened this issue May 9, 2022 · 4 comments
Closed

Calculate the ACC error during train the model #206

VivizSun opened this issue May 9, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@VivizSun
Copy link

VivizSun commented May 9, 2022

When I am training the model, there is an error in calculating ACC.
Could you provide a way for me to solve it?

Error message:Tensor holds the wrong type, it holds int, but desires to be int64_t.
11

pred and label type
pred
label_orig

@xperzy
Copy link
Collaborator

xperzy commented May 9, 2022

Hello, Thanks for the issue, we don't see this problem in our env, could you please provide your paddle version ?
A quick fix is to add a type conversion in the loop where the data is loaded from dataloader, such as:

for batch_id, data in enumerate(dataloader):
    # get data
    images = data[0]
    label = data[1]
    # add data conversion to int64
    label = label.astype('int64')

P.S.,
From the screenshot I saw the main_single_gpu.py may not be the updated code in our implementation, could you please refer to our new impl https://github.com/BR-IDL/PaddleViT/blob/develop/image_classification/SwinTransformer/main_multi_gpu.py

@xperzy xperzy self-assigned this May 9, 2022
@xperzy xperzy added the bug Something isn't working label May 9, 2022
@VivizSun
Copy link
Author

Hi xperzy,
My env are as shown below.
Package Version


appdirs 1.4.4
astor 0.8.1
certifi 2021.10.8
charset-normalizer 2.0.12
cityscapesScripts 2.2.0
colorama 0.4.4
coloredlogs 15.0.1
cycler 0.11.0
decorator 5.1.1
fonttools 4.33.3
humanfriendly 10.0
idna 3.3
kiwisolver 1.4.2
lmdb 1.3.0
matplotlib 3.5.1
numpy 1.19.3
opencv-python 4.5.5.64
packaging 21.3
paddlepaddle-gpu 2.2.2.post112
Pillow 9.1.0
pip 21.2.4
protobuf 3.20.1
pyparsing 3.0.8
pyquaternion 0.9.9
pyreadline 2.1
python-dateutil 2.8.2
PyYAML 6.0
requests 2.27.1
setuptools 61.2.0
six 1.16.0
tqdm 4.64.0
typing 3.7.4.3
typing_extensions 4.2.0
urllib3 1.26.9
wheel 0.37.1
wincertstore 0.2
yacs 0.1.8


P.S.,
I use the SwinTransformer model for image classification.

@xperzy
Copy link
Collaborator

xperzy commented May 12, 2022

@VivizSun Is your problem sovled by using : label = label.astype('int64') ?

@VivizSun
Copy link
Author

@xperzy Yes, thank you very much.

@xperzy xperzy closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants