2016-06-30 6 views
0

は、ここで私が持っているものです。numpy配列を使って単語のマッピングから単語を取り戻すにはどうしたらいいですか? [Tensorflow RNN]テキスト分類

vocab_processor = skflow.preprocessing.VocabularyProcessor(MAX_DOCUMENT_LENGTH) 
X_train = np.array(list(vocab_processor.fit_transform(X_train))) 
X_test = np.array(list(vocab_processor.transform(X_test))) 

を今、それは、単語辞書中の単語のIDのnumpyの配列を作成します。 辞書からこれらの単語を検索するにはどうすればよいですか?

reverese(document)という機能がありますが、この場合は機能しません。マーカーを含むリターンリストです。

['What is most beautiful in <UNK> men is something feminine' 
"The camera makes everyone a tourist in other people's reality" 
'<UNK> in reality is the worst of all evils because' ..., 
'<UNK> aware that no bank would do this as they' 
'<UNK> keep sending you many details through the post like' 
'<UNK> banking transactions should be conducted in a secure place'] 

答えて

0

これは、あなたIDを与える:単語

w_dict = {v:k for k,v in vocab_processor.vocabulary_._mapping.items()} 

次に、あなたが得ることができる言葉:

words = w_dict.values() 
関連する問題