# - email: [email protected] # - git: https://github.com/DeokO # - Date: 2018.01.09. #################################################### ##################################### # Import modules ##################################### import tensorflow as tf import numpy as np from Ch01_Data_load import data_load ########################## # max length of document ########################## TRAIN_DOC, TRAIN_LABEL, _, _, TEST_DOC, TEST_LABEL, _, _ = data_load.data_load( ) max_doc_length = max([len(x.split(" ")) for x in TRAIN_DOC]) ########################## # Vocabulary Processor ########################## # Create the vocabularyprocessor object, setting the max lengh of the documents. vocab_processor = tf.contrib.learn.preprocessing.VocabularyProcessor( max_doc_length, min_frequency=5) # Transform the documents using the vocabulary. x = np.array(list(vocab_processor.fit_transform(TRAIN_DOC))) ## Extract word:id mapping from the object. vocab_dict = vocab_processor.vocabulary_._mapping # len(vocab_dict) #72844
####################################################################### import os os.environ['FOR_DISABLE_CONSOLE_CTRL_HANDLER'] = '1' ##################################### # Import modules ##################################### from Ch01_Data_load import data_load from Ch05_TextRNN_word_attention.Text_RNN_word_attention_config import * from Ch05_TextRNN_word_attention.Text_RNN_word_attention_model import * information = '' FLAGS.WRITER += information ################################################################################ # DATA LOAD ################################################################################ TRAIN_DOC, TRAIN_LABEL, TRAIN_LABEL_POS, TRAIN_LABEL_NEG, TEST_DOC, TEST_LABEL, TEST_LABEL_POS, TEST_LABEL_NEG = data_load.data_load( ) # restore vocabularyprocessor object vocab_processor = tf.contrib.learn.preprocessing.VocabularyProcessor.restore( FLAGS.Vocab_Processor_PATH) ################################################################################ # Start Session / Network Scratch / Save Check Point ################################################################################ # Start Session sess = tf.Session() print("Session Ready!") model = MODEL(sess=sess, FLAGS=FLAGS) # Initialization sess.run(tf.global_variables_initializer())