• 카테고리

    질문 & 답변
  • 세부 분야

    자연어 처리

  • 해결 여부

    해결됨

201_classify_text_with_bert_tfhub_Kor.ipynb 오류

24.04.07 00:48 작성 조회수 79

0

안녕하세요?
201_classify_text_with_bert_tfhub_Kor.ipynb 소스 수행 시 아래와 같은 오류가 납니다.
구글 colab gpu에서 돌리고 있습니다. (오류 이미지도 같이 첨부합니다.)

왜 오류가 나는지 답변 부탁 드립니다.

ValueError                                Traceback (most recent call last)
<ipython-input-17-3b4b1d94b15e> in <cell line: 1>()
----> 1 classifier_model = build_classifier_model()
      2 bert_raw_result = classifier_model(tf.constant(text_test))
      3 
      4 print(bert_raw_result)
      5 print(tf.sigmoid(bert_raw_result))


7 frames


/usr/local/lib/python3.10/dist-packages/keras/src/backend/common/keras_tensor.py in __array__(self)
     59 
     60     def __array__(self):
---> 61         raise ValueError(
     62             "A KerasTensor is symbolic: it's a placeholder for a shape "
     63             "an a dtype. It doesn't have any actual numerical value. "

ValueError: Exception encountered when calling layer 'preprocessing' (type KerasLayer).

A KerasTensor is symbolic: it's a placeholder for a shape an a dtype. It doesn't have any actual numerical value. You cannot convert it to a NumPy array.

Call arguments received by layer 'preprocessing' (type KerasLayer):
  • inputs=<KerasTensor shape=(None,), dtype=string, sparse=None, name=text>
  • training=None


답변 2

·

답변을 작성해보세요.

1

다음과 같이 수정하시면 됩니다.

(기존)

!pip install -q -U tensorflow-text

!pip install -q tf-models-official

(수정)

!pip install -U "tensorflow-text==2.13.*"

!pip install "tf-models-official==2.13.*"

이 교재는 Google Tutorial의 https://www.tensorflow.org/text/tutorials/classify_text_with_bert 교재를 IMBD 대신 한글 naver movie 데이터로 제가 customizing 한 것인데 원래의 영문 tutorial 도 수정이 되어있네요. github 교재 source도 수정해 놓았습니다. 불편을 드려 죄송합니다.

제가 새롭게 고쳐서 실행해 보니 T4 GPU 기준 6시간 걸리네요. 예전 보다 시간이 훨씬 길어졌는데 아마도 Google 에서 무료 GPU 에 대한 지원을 낮춘 것으로 보입니다.
감사합니다.

0

박정아님의 프로필

박정아

질문자

2024.04.07

이것은 6시간 돌리다 끊어져서 다시 돌려 봐야 할 것 같습니다.
답변 감사합니다.