Hello, I am trying to use BioBERT to fine tune i2b2-2010 dataset which has three entities to be extracted: treatment, test, and problem. The only code I changed in run_ner.py is get_labels
function in class NerProcessor. I changed it to below:
def get_labels(self):
return ["O", "X", "[CLS]", "[SEP]", "B-test", "I-test", "B-problem", "I-problem", "B-treatment", "I-treatment"]
I also changed training batch size to 16 due to my GPU memory.
However, when I run run_ner.py, I got the following error:
Traceback (most recent call last):
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1628, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension size must be evenly divisible by 896 but is 22528 for 'loss/Reshape_1' (op: 'Reshape') with input shapes: [2048,11], [3] and with input tensors computed as partial shapes: input[1] = [?,128,7].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "run_ner.py", line 630, in <module>
tf.app.run()
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "run_ner.py", line 555, in main
estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2409, in train
rendezvous.raise_errors()
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/error_handling.py", line 128, in raise_errors
six.reraise(typ, value, traceback)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2403, in train
saving_listeners=saving_listeners
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 354, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1207, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1237, in _train_model_default
features, labels, model_fn_lib.ModeKeys.TRAIN, self.config)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2195, in _call_model_fn
features, labels, mode, config)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1195, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 2479, in _model_fn
features, labels, is_export_mode=is_export_mode)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1259, in call_without_tpu
return self._call_model_fn(features, labels, is_export_mode=is_export_mode)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py", line 1533, in _call_model_fn
estimator_spec = self._model_fn(features=features, **kwargs)
File "run_ner.py", line 412, in model_fn
num_labels, use_one_hot_embeddings)
File "run_ner.py", line 382, in create_model
logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 7])
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 6482, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1792, in __init__
control_input_ops)
File "/home/daniel/PycharmProjects/biobert/.venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
raise ValueError(str(e))
ValueError: Dimension size must be evenly divisible by 896 but is 22528 for 'loss/Reshape_1' (op: 'Reshape') with input shapes: [2048,11], [3] and with input tensors computed as partial shapes: input[1] = [?,128,7].
I can successfully run NCBI-disease dataset. So is it because of the different labels?
Any idea why this is happening and how I can fix it? Any help is highly appreciated!