2017-12-06 10 views
0

해당 레이블이 '0'또는 '1'(스팸/비 스팸 인 경우) 인 .tfrecord 데이터 세트의 텍스트 문서 (전자 메일)가 있습니다. 이 모든 데이터 세트는 이미 .tfrecord 파일 형식입니다. 전자 메일을 말로 표현하려고합니다. 나는 그것을 돕는 모든 도우미 방법을 가지고 있지만, 나는 여전히 tfrecords에 익숙하지 않다.TFRecords 파일을 사용한 텍스트 전처리

def read_from_tfrecord(filenames): 

    tfrecord_file_queue = tf.train.string_input_producer([filenames], name='queue') 
    reader = tf.TFRecordReader() 

    _, tfrecord_serialized = reader.read(tfrecord_file_queue) 

    tfrecord_features = tf.parse_single_example(tfrecord_serialized, 
         features={ 
          'label': tf.FixedLenFeature([], tf.int64), 
          'text': tf.FixedLenFeature([], tf.string), 
         }, name='features') 

    text = tfrecord_features['text'] 
    label = tfrecord_features['label'] 

    return label, text 
나는 내가 '텍스트'를 수정하는 내 헬퍼 메소드를 사용하려는 경우 진행 방법을

이 내가 tf_record 파일을 읽고 지금까지이 무엇인가?

답변

0

tf.parse_single_example은 키를 텐서로 매핑하는 사전을 반환합니다. 즉, text은 텐서입니다. 따라서 텐서 연산을 사용하여 단어의 모음으로 변환 할 수 있습니다. 예를 들어

는 :

text = tf.unique(tf.string_split([text]).values).y 

이 이메일에있는 모든 고유 한 토큰 (공백으로 분리)를 반환합니다. 구두점 및 기타 사례를 처리하기 위해 더 많은 작업을 추가해야 할 것입니다.