[자연어처리] 패딩(Padding) : 다른 숫자로 패딩하는 방법 (파이썬)
이전 글들에서 pad_sequences() 함수를 사용하여 패딩을 구현하고, 길이 지정 등 다양하게 패딩하는 방법에 대해서 계속 살펴보았는데요, 이번 글에서는 0이 아닌 다른 값으로 패딩하는 방법에 대해서 살펴보겠습니다. 먼저, pad_sequences() 함수를 이용하여 길이 10의 제로패딩을 하는 코드를 작성해보겠습니다. import numpy as np from tensorflow.keras.preprocessing.text import Tokenizer sentences = [['place', 'tree'], ['tree', 'nice', 'green'], ['nice', 'sky', 'and', 'tree'], ['bird', 'tree']] #정수 인코딩 tokenizer= Tokenizer(..
더보기