IBM / low-resource-text-classification-framework

Research framework for low resource text classification that allows the user to experiment with classification models and active learning strategies on a large number of sentence classification datasets, and to simulate real-world scenarios. The framework is easily expandable to new classification models, active learning strategies and datasets.
Apache License 2.0
97 stars 20 forks source link

Unable to port 'experiment runner balanced' to BERT #4

Closed nikhilbchilwant closed 3 years ago

nikhilbchilwant commented 3 years ago

I was able to run all the experiments with default configuration i.e. for ModelType.NB. I am trying to run the same code for BERT but I am getting below dimensional error.

tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found. (0) Invalid argument: assertion failed: [Condition x == y did not hold element-wise:] [x (sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [50 1] [y (sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [50 100] [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/assert_equal_1/Assert/Assert (defined at /nethome/nchilwant/projects/low-resource-text-classification-framework/lrtc_lib/train_and_infer_service/train_and_infer_hf.py:145) ]] [[gradient_tape/tf_bert_for_sequence_classification/bert/embeddings/position_embeddings/embedding_lookup/Reshape/_696]] (1) Invalid argument: assertion failed: [Condition x == y did not hold element-wise:] [x (sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [50 1] [y (sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [50 100] [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/assert_equal_1/Assert/Assert (defined at /nethome/nchilwant/projects/low-resource-text-classification-framework/lrtc_lib/train_and_infer_service/train_and_infer_hf.py:145) ]]

See detailed log in the attached file. How do I fix it? BERT_active_learning.log

arielge commented 3 years ago

Hi @nikhilbchilwant, It appears to be some sort of incompatibility with a recent version of the HuggingFace transformers library. Can you downgrade to transformers>=2.5.1,<=3.5 and try running again? Let me know if this resolves your issue.