Skip to content

Classification backbone with Vit results in argument 'input' (position1) must be Tensor, not tuple #1616

Closed Answered by ericspod
kavmar asked this question in General
Discussion options

You must be logged in to vote

The issue is that the network puts out a tuple of values and you only want the first one, there's a few ways to create a ad-hoc solution. You can inherit from ViT with only a __call__ method which returns the first value from the parent call:

class MyViT(ViT):
    def __call__(self,*args,**kwargs): return super().__call__(*args,**kwargs)[0]

You could instead define an Inferer subclass to do the equivalent thing:

class MySimpleInferer(SimpleInferer):
    def __call__(self,*args,**kwargs): return super().__call__(*args,**kwargs)[0]

You would use this in place of the default SimpleInferer class that the trainer/evaluator classes use. Both these throw out the hidden states so if you want thes…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kavmar
Comment options

@ericspod
Comment options

Answer selected by KumoLiu
@kavmar
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1614 on January 15, 2024 03:27.