GateNLP / gate-lf-pytorch-json

PyTorch wrapper for the LearningFramework GATE plugin
Apache License 2.0
1 stars 2 forks source link

Chunking with a numerical feature causes an exception #43

Closed johann-petrak closed 5 years ago

johann-petrak commented 5 years ago

When the data from the LF includes a numerical feature when training a sequence-based chunking model we get the following error:

vals4pt = torch.FloatTensor(vals).t()
RuntimeError: t() expects 2D tensor, but self is 3D

at line 74 in classificationmodule.py

Need to check if numeric features are also a problem with non-sequence classification.

johann-petrak commented 5 years ago

There are probably two problems here:

1) we generate a rubbish network architecture: we generate a linear layer which gets as many inputs as there are numeric features . Especially if we only have one numeric feature this does not make sense as we get a Linear(1,1) Layer.

2) we should simply concatenate the numeric inputs with the concatenation of all the embeddings for the non-numeric features instead!

Overall this means we change the architecture AND the way how we forward the values.

johann-petrak commented 5 years ago

Fixed as of 237ef31362a5416bb3ebbf90550e9e4ff296a98a