<s> '''<STR_LIT>''' <EOL> from __future__ import print_function <EOL> import numpy as np <EOL> np . random . seed ( <NUM_LIT> ) <EOL> from keras . preprocessing import sequence <EOL> from keras . models import Model <EOL> from keras . layers import Dense , Dropout , Embedding , LSTM , Input , merge <EOL> from keras . datasets import imdb <EOL> max_features = <NUM_LIT> <EOL> maxlen = <NUM_LIT:100> <EOL> batch_size = <NUM_LIT:32> <EOL> print ( '<STR_LIT>' ) <EOL> ( X_train , y_train ) , ( X_test , y_test ) = imdb . load_data ( nb_words = max_features , <EOL> test_split = <NUM_LIT> ) <EOL> print ( len ( X_train ) , '<STR_LIT>' ) <EOL> print ( len ( X_test ) , '<STR_LIT>' ) <EOL> print ( "<STR_LIT>" ) <EOL> X_train = sequence . pad_sequences ( X_train , maxlen = maxlen ) <EOL> X_test = sequence . pad_sequences ( X_test , maxlen = maxlen ) <EOL> print ( '<STR_LIT>' , X_train . shape ) <EOL> print ( '<STR_LIT>' , X_test . shape ) <EOL> y_train = np . array ( y_train ) <EOL> y_test = np . array ( y_test ) <EOL> sequence = Input ( shape = ( maxlen , ) , dtype = '<STR_LIT>' ) <EOL> embedded = Embedding ( max_features , <NUM_LIT> , input_length = maxlen ) ( sequence ) <EOL> forwards = LSTM ( <NUM_LIT:64> ) ( embedded ) <EOL> backwards = LSTM ( <NUM_LIT:64> , go_backwards = True ) ( embedded ) <EOL> merged = merge ( [ forwards , backwards ] , mode = '<STR_LIT>' , concat_axis = - <NUM_LIT:1> ) <EOL> after_dp = Dropout ( <NUM_LIT:0.5> ) ( merged ) <EOL> output = Dense ( <NUM_LIT:1> , activation = '<STR_LIT>' ) ( after_dp ) <EOL> model = Model ( input = sequence , output = output ) <EOL> model . compile ( '<STR_LIT>' , '<STR_LIT>' , metrics = [ '<STR_LIT>' ] ) <EOL> print ( '<STR_LIT>' ) <EOL> model . fit ( X_train , y_train , <EOL> batch_size = batch_size , <EOL> nb_epoch = <NUM_LIT:4> , <EOL> validation_data = [ X_test , y_test ] ) </s>
