daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. left_branch = Sequential()
  3. left_branch.add(Dense(32, input_dim=X_train.shape[1]))
  4. left_branch.add(Embedding(input_dim=vocab_size+1, output_dim=2, input_length=4))
  5. left_branch.add(Flatten())
  6.  
  7. right_branch = Sequential()
  8. right_branch.add(Dense(32, input_dim=X_train_tfidf.shape[1]))
  9. merged = Merge([left_branch, right_branch], mode='concat')
  10.  
  11. model = Sequential()
  12. model.add(merged)
  13. model.add(Dense(32, activation='tanh'))
  14.  
  15. #block 1
  16. model.add(Dense(units=64, activation='tanh', name='first'))
  17. #model.add(Dropout(0.005))
  18. model.add(BatchNormalization())
  19. block 2
  20. model.add(Dense(units=64, activation='relu', name='second'))
  21. #model.add(Dropout(0.005))
  22. model.add(BatchNormalization())
  23. #block 3
  24. model.add(Dense(units=128, activation='relu', name='third'))
  25. #model.add(Dropout(0.005))
  26. model.add(BatchNormalization())
  27. #block 4
  28. model.add(Dense(units=128, activation='relu', name='fourth'))
  29. #model.add(Dropout(0.005))
  30. model.add(BatchNormalization())
  31. #block 5
  32. model.add(Dense(units=256, activation='relu', name='fifth'))
  33. #model.add(Dropout(0.005))
  34. model.add(BatchNormalization())
  35. #block 6
  36. model.add(Dense(units=256, activation='relu', name='sixth'))
  37. #model.add(Dropout(0.005))
  38. model.add(BatchNormalization())
  39. #block 7
  40. model.add(Dense(units=128, activation='relu', name='seventh'))
  41. #model.add(Dropout(0.005))
  42. model.add(BatchNormalization())
  43. block 8
  44. model.add(Dense(units=64, activation='tanh', name='eighth'))
  45. #model.add(Dropout(0.005))
  46. model.add(BatchNormalization())
  47. model.add(Dense(1, activation='sigmoid')) #sigmoid
  48. sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
  49. model.summary()
  50. #final_model.compile(optimizer='rmsprop', loss='categorical_crossentropy')
  51. model.compile(loss='binary_crossentropy', optimizer=sgd, metrics=['accuracy']) #sgd3 #loss='mse'
  52. model.fit([X_train, X_train_tfidf], y_train,
  53.          validation_split=0.2, #validation_data=(np.array(X_test.todense()), y_test),
  54.          epochs=5, batch_size=32)
RAW Paste Data
Top