# AI 이론/TensorFlow Function

TensorFlow tf.strings

alz 2022. 5. 4. 09:59

TensorFlow 의 tf.strings 메서드 입니다.

 

 

tf.strings.substr()

tf.strings.substr(
    input, pos, len, unit='BYTE', name=None
)

input Tensor를 pos 인덱스부터 len길이전까지 짤라서 사용합니다.

 

input = [b'Hello', b'World']
position = 1
length = 3

output = tf.strings.substr(input,position,length) 
# 결과
output = [b'ell', b'orl']

각각의 데이터에 대해서 적용됩니다. Hello 의 index [1:3], World 의 index[1:3]

 

 

tf.strings.regex_replace()

tf.strings.regex_replace(
    input, pattern, rewrite, replace_global=True, name=None
)

input의 elements안에 pattern 값이 있다면 그값을 rewrite값으로 대체합니다.

파이썬의 정규표현식과 매우 흡사합니다 

tf.strings.regex_replace("Text with tags.<br /><b>contains html</b>",
                         "<[^>]+>", " ")
 
 # outputs 
 b'Text with tags.	contains html'

'# AI 이론 > TensorFlow Function' 카테고리의 다른 글

TensorFlow tf.lookup  (0) 2022.05.04
TensorFlow batch,window 메서드  (0) 2022.05.03