Я читаю текстовые файлы, хранящиеся в моей базе данных, и все они имеют разные размеры. Когда я запускаю свой код, он внезапно останавливается и выдает эту ошибку. Нигде не найдено соответствующих ответов. Я попытался изменить max_seq_embeddings, но все еще не работает. Как только я сталкиваюсь с файлом длиной 3619, возникает ошибка.
YES <class 'str'> 1814
YES <class 'str'> 1334
YES <class 'str'> 3619
Traceback (most recent call last):
File "C:/Users/DeLL/PycharmProjects/Phase1/venv/src/Main.py", line 24, in <module>
output = model.predict(data.text)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\bert.py", line 77, in predict
logits = self.model(input_ids, segment_ids, input_mask,valid_ids)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 891, in __call__
outputs = self.call(cast_inputs, *args, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\model.py", line 55, in call
sequence_output = self.bert([input_word_ids, input_mask, input_type_ids],**kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 891, in __call__
outputs = self.call(cast_inputs, *args, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 708, in call
convert_kwargs_to_constants=base_layer_utils.call_context().saving)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 860, in _run_internal_graph
output_tensors = layer(computed_tensors, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\bert_modeling.py", line 197, in __call__
return super(BertModel, self).__call__(inputs, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 891, in __call__
outputs = self.call(cast_inputs, *args, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\bert_modeling.py", line 217, in call
word_embeddings=word_embeddings, token_type_ids=input_type_ids)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\bert_modeling.py", line 329, in __call__
return super(EmbeddingPostprocessor, self).__call__(inputs, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 891, in __call__
outputs = self.call(cast_inputs, *args, **kwargs)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\src\bert_modeling.py", line 355, in call
tf.slice(self.position_embeddings, [0, 0], [seq_length, width]),
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\ops\array_ops.py", line 866, in slice
return gen_array_ops._slice(input_, begin, size, name=name)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\ops\gen_array_ops.py", line 9212, in _slice
input, begin, size, name=name, ctx=_ctx)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\ops\gen_array_ops.py", line 9251, in _slice_eager_fallback
ctx=_ctx, name=name)
File "C:\Users\DeLL\PycharmProjects\Phase1\venv\lib\site-packages\tensorflow_core\python\eager\execute.py", line 67, in quick_execute
six.raise_from(core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Expected size[0] in [0, 512], but got 891 [Op:Slice]
Process finished with exit code 1
Вот ссылка на все используемые файлы. https://github.com/kamalkraj/BERT-NER-TF