-
Hi, I am trying to use ViT as follows: net = monai.networks.nets.ViT(spatial_dims=2, in_channels=1, img_size=(400, 400), proj_type='conv', patch_size=(64, 64), but I am running into the same issue as reported here: #464 return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) It has been concluded that the API will be enhanced by hidden_states_out, but I do not see it implemented - apparently due to design. MONAI version: 1.3.0 Thanks for advice |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @kavmar, I think you can take Hope it helps, thanks! |
Beta Was this translation helpful? Give feedback.
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:You could instead define an
Inferer
subclass to do the equivalent thing: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…