Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

'NoneType' object has no attribute 'log_softmax' #10

Closed
khawar-islam opened this issue Jul 1, 2021 · 3 comments
Closed

'NoneType' object has no attribute 'log_softmax' #10

khawar-islam opened this issue Jul 1, 2021 · 3 comments

Comments

@khawar-islam
Copy link

I am using standard loss function nn.CrossEntropyLoss(). It give the following error, please let me know, can we use nn.CrossEntropyLoss()?

Traceback (most recent call last):

  File "/raid/khawar/PycharmProjects/thesis/train.py", line 487, in <module>
    loss = LOSS(outputs, labels)
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1047, in forward
    return F.cross_entropy(input, target, weight=self.weight,
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/torch/nn/functional.py", line 2693, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/raid/khawar/anaconda3/envs/vision-transformer-pytorch/lib/python3.8/site-packages/torch/nn/functional.py", line 1672, in log_softmax
    ret = input.log_softmax(dim)
AttributeError: 'NoneType' object has no attribute 'log_softmax'
@btgraham
Copy link
Contributor

btgraham commented Jul 1, 2021

What are you running to get this error? Are you running the LeViT source code or something else?

@khawar-islam
Copy link
Author

I am using Levit code from the below repository and integrated this code in my codebase.
https://github.com/lucidrains/vit-pytorch/blob/main/vit_pytorch/levit.py

@btgraham
Copy link
Contributor

btgraham commented Jul 1, 2021

Please use the models in levit.py.
Sample training code using Timm is in https://github.com/facebookresearch/LeViT/blob/main/engine.py .

@btgraham btgraham closed this as completed Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants