반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[tf] 유사성 측정 본문

Python/RNN

[tf] 유사성 측정

닉의네임 2022. 8. 21. 18:47
반응형
import tensorflow as tf
import tensorflow_text as text


hypotheses = tf.ragged.constant([['captain', 'of', 'the', 'delta', 'flight'],
                                 ['the', '1990', 'transcript']])
references = tf.ragged.constant([['delta', 'air', 'lines', 'flight'],
                                 ['this', 'concludes', 'the', 'transcript']])


result = text.metrics.rouge_l(hypotheses, references)
print('F-Measure: %s' % result.f_measure)
print('P-Measure: %s' % result.p_measure)
print('R-Measure: %s' % result.r_measure)



# Compute ROUGE-L with alpha=0
result = text.metrics.rouge_l(hypotheses, references, alpha=0)
print('F-Measure (alpha=0): %s' % result.f_measure)
print('P-Measure (alpha=0): %s' % result.p_measure)
print('R-Measure (alpha=0): %s' % result.r_measure)



# Compute ROUGE-L with alpha=1
result = text.metrics.rouge_l(hypotheses, references, alpha=1)
print('F-Measure (alpha=1): %s' % result.f_measure)
print('P-Measure (alpha=1): %s' % result.p_measure)
print('R-Measure (alpha=1): %s' % result.r_measure)

 

반응형

'Python > RNN' 카테고리의 다른 글

[tf] RNN을 사용한 텍스트 분류  (0) 2022.08.17
[tf] rnn project  (1) 2022.07.10
RNN  (0) 2022.01.09
Comments