Guest User

Untitled

a guest
Mar 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. def _build_network(self, vocab_size, maxlen, embedding_dimension=256, hidden_units=256, trainable=False):
  2. print('Build model...')
  3. model = Sequential()
  4. print('Reached here')
  5.  
  6. model.add(Embedding(vocab_size, embedding_dimension, input_length=maxlen, embeddings_initializer='glorot_normal'))
  7. print('embedding done')
  8.  
  9. model.add(Convolution1D(hidden_units, 3, kernel_initializer='he_normal', padding='valid', activation='sigmoid',
  10. input_shape=(1, maxlen)))
  11. # model.add(MaxPooling1D(pool_size=3))
  12. model.add(Convolution1D(hidden_units, 3, kernel_initializer='he_normal', padding='valid', activation='sigmoid',
  13. input_shape=(1, maxlen - 2)))
  14. print('conv1dcomplete')
  15. # model.add(MaxPooling1D(pool_size=3))
  16.  
  17. # model.add(Dropout(0.25))
  18.  
  19. model.add(LSTM(hidden_units, kernel_initializer='he_normal', activation='sigmoid', dropout=0.5, return_sequences=True))
  20. #print('Reached here')
  21.  
  22. model.add(LSTM(hidden_units, kernel_initializer='he_normal', activation='sigmoid', dropout=0.5))
  23.  
  24. model.add(Dense(hidden_units, kernel_initializer='he_normal', activation='sigmoid'))
  25. model.add(Dense(2))
  26. model.add(Activation('softmax'))
  27. adam = Adam(lr=0.0001)
  28. model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy'])
  29. print('No of parameter:', model.count_params())
  30. print(model.summary())
  31. return model
Add Comment
Please, Sign In to add comment