Hi All,
I am currently attempting to use Fastai-v2 for training a Siamese Network on the task of SNLI. I am using the siamese tutorial, which uses images, as a template. However, I have fit a couple of roadblocks in transferring the tutorial to textual data. The current issue I am facing is with getting the data in the correct format of (premise, hypothesis, label) that the SNLI task comes in.
The most successful attempt is located in this google colab notebook: https://drive.google.com/file/d/1XmANd5SOWUpx0BAyCRyUpXABd6HCVSm6/view?usp=sharing
The issue comes when attempting to generate a batch using the dataloaders.one_batch function giving the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-97-ccb93b9fbe07> in <module>()
----> 1 dls.one_batch()
12 frames
/usr/local/lib/python3.6/dist-packages/fastai2/torch_core.py in _f(self, *args, **kwargs)
269 def _f(self, *args, **kwargs):
270 cls = self.__class__
--> 271 res = getattr(super(TensorBase, self), fn)(*args, **kwargs)
272 return retain_type(res, self)
273 return _f
ValueError: only one element tensors can be converted to Python scalars
I’ve tried to localize exactly what call is trigger this issue and what data is being produced, but haven’t been able to track it down.
I see that the underlying data is correct by looking at the dataset within the dataloader:
((TensorText([11, 72, 27, 14, 10, 34, 73, 15, 45, 18, 74, 16, 29, 37, 35, 9]),
TensorText([19, 0, 17, 24, 10, 34, 9])),
TensorCategory(0))
which shows the two sentences and the label (though I would have expected the two tensortext’s to be of type TextTuple (see google colab)).
I’ve also looked through previous attempts to use siamese networks for textual data in fastai, but they are using a previous fastai version.
Any help would be greatly appreciated!