[pytorch] TypeError: object of type 'int' has no len() in torchtext


[pytorch] TypeError: object of type 'int' has no len() in torchtext

오늘 다룰 에러는 TypeError: object of type 'int' has no len() 이다. /opt/conda/lib/python3.9/site-packages/torchtext/legacy/data/field.py in <genexpr>(.0) 246 return minibatch 247 if self.fix_length is None: --> 248 max_len = max(len(x) for x in minibatch) 249 else: 250 max_len = self.fix_length + ( TypeError: object of type 'int' has no len() 전체적인 에러 형식은 위와 같다. 이 에러를 검색하면, int 타입에 len()을 붙여서 에러가 났다는 말만 나오는데,,,, torchtext에서는 나오지 않길래 해결 방안을 작성하려고 한다. 결론부터 말하면, torchtext의 LABEL이 들어가는 Field에 이를 LABEL이라고 명시하...


#field #pytorch #torchtext #자연어처리

원문링크 : [pytorch] TypeError: object of type 'int' has no len() in torchtext