레이블이 error인 게시물을 표시합니다. 모든 게시물 표시
레이블이 error인 게시물을 표시합니다. 모든 게시물 표시

2022년 12월 6일 화요일

huggingface pipeline 기능을 사용시에 truncate 하는 방법 (에러 : RuntimeError: The size of tensor a (1185) must match the size of tensor b (512) at non-singleton dimension 1))

  •  발생 에러
    • RuntimeError: The size of tensor a (1185) must match the size of tensor b (512) at non-singleton dimension 1
    • input이 model input size보다 더커서 발생하는 문제
    • tokenizer 선언히 truncate 설정해줬지만, pipeline 사용할 때는, pipeline 호출 할때, 다시 truncate를 설정해줘야 함

  • 해결 방법

from transformers import pipeline
model_name = "test_trainer/checkpoint-423"
# load model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained("klue/bert-base", padding=True, truncation=True, max_length=512)

classifier = pipeline("text-classification", model=model, tokenizer=tokenizer, device=0)
classifier(text, padding=True, truncation=True)

2022년 10월 23일 일요일

2022년 10월 21일 금요일

[ubuntu에서 unzip 갑자기 안될때, 대용량 압축 해제의 경우] End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive

  • 에러 발생한 커맨드
    • unzip abc.zip
  • 에러 메세지
    • Archive: abc.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of DIETClassifier-openlab.zip or DIETClassifier-openlab.zip.zip, and cannot find abc.zip.ZIP, period
  • 해결방법
    • jar 패키지 설치
      • sudo apt-get install fastjar
    • jar 이용해서 압축 풀기
      • jar xvf abc.zip

2022년 10월 20일 목요일

[내장 함수의 명을 사용하는 경우 혹은 동일한 변수명으로 잘못 명명하는 경우] TypeError: '_io.TextIOWrapper' object is not callable

  •  에러 발생
    • TypeError: '_io.TextIOWrapper' object is not callable
  • 이유
    • list와 같은 내장 함수를 변수명으로 사용
    • f = open('./path','w') 와 f.write("hi") 사이에 f = lambda x: x in exclusion_tags 를 선언하였음
    • 변수명 조심 + 변수명은 대충 짓지 말기

[konlpy import시 발생하는 JVM 문제] "JVMNotFoundException: No JVM shared library file (libjvm.so) found. Try setting up the JAVA_HOME environment variable properly"

  •  문제
    • konply import시 아래와 같은 에러가 발생
      • "JVMNotFoundException: No JVM shared library file (libjvm.so) found. Try setting up the JAVA_HOME environment variable properly"
  • 해결방법
    • sudo apt install default-jdk

[tweepy 패키지 버전 문제] konlpy 패키지 import 에러 해결 (AttributeError: module 'tweepy' has no attribute 'StreamListener')

 

  • 문제

    • konlpy import 시 발생하는 tweepy 패키지 버전 문제

  • 해결방안
    • pip install tweepy==3.10.0
    • tweepy를 downgrade하고 3.10.0 으로 재설치하면 해결됨.