1+ from __future__ import print_function
12# author - Richard Liao
23# Dec 26 2016
34import numpy as np
@@ -43,7 +44,7 @@ def clean_str(string):
4344 return string .strip ().lower ()
4445
4546data_train = pd .read_csv ('~/Testground/data/imdb/labeledTrainData.tsv' , sep = '\t ' )
46- print data_train .shape
47+ print ( data_train .shape )
4748
4849from nltk import tokenize
4950
@@ -79,8 +80,8 @@ def clean_str(string):
7980print ('Total %s unique tokens.' % len (word_index ))
8081
8182labels = to_categorical (np .asarray (labels ))
82- print ('Shape of data tensor:' , data .shape )
83- print ('Shape of label tensor:' , labels .shape )
83+ print (( 'Shape of data tensor:' , data .shape ) )
84+ print (( 'Shape of label tensor:' , labels .shape ) )
8485
8586indices = np .arange (data .shape [0 ])
8687np .random .shuffle (indices )
@@ -94,8 +95,8 @@ def clean_str(string):
9495y_val = labels [- nb_validation_samples :]
9596
9697print ('Number of positive and negative reviews in traing and validation set' )
97- print y_train .sum (axis = 0 )
98- print y_val .sum (axis = 0 )
98+ print ( y_train .sum (axis = 0 ) )
99+ print ( y_val .sum (axis = 0 ) )
99100
100101GLOVE_DIR = "/ext/home/analyst/Testground/data/glove"
101102embeddings_index = {}
@@ -138,7 +139,7 @@ def clean_str(string):
138139 metrics = ['acc' ])
139140
140141print ("model fitting - Hierachical LSTM" )
141- print model .summary ()
142+ print ( model .summary () )
142143model .fit (x_train , y_train , validation_data = (x_val , y_val ),
143144 nb_epoch = 10 , batch_size = 50 )
144145
0 commit comments