Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. if labels[index] == 0 :
  2. Y_train[i, :] = [1.0, 0.0]
  3. elif labels[index] == 1 :
  4. Y_train[i, :] = [0.0, 1.0]
  5. else:
  6. Y_train[i, :] = [0.5, 0.5]
  7.  
  8. model = Sequential()
  9. model.add(Conv1D(32, kernel_size=3, activation='elu', padding='same',
  10. input_shape=(15,512)))
  11. model.add(Conv1D(32, kernel_size=3, activation='elu', padding='same'))
  12. model.add(Conv1D(32, kernel_size=3, activation='elu', padding='same'))
  13. model.add(Conv1D(32, kernel_size=3, activation='elu', padding='same'))
  14. model.add(Dropout(0.25))
  15. model.add(Conv1D(32, kernel_size=2, activation='elu', padding='same'))
  16. model.add(Conv1D(32, kernel_size=2, activation='elu', padding='same'))
  17. model.add(Conv1D(32, kernel_size=2, activation='elu', padding='same'))
  18. model.add(Conv1D(32, kernel_size=2, activation='elu', padding='same'))
  19. model.add(Dropout(0.25))
  20. model.add(Dense(256, activation='tanh'))
  21. model.add(Dense(256, activation='tanh'))
  22. model.add(Dropout(0.5))
  23. model.add(Flatten())
  24. model.add(Dense(2, activation='sigmoid'))
  25.  
  26. model.compile(loss='categorical_crossentropy',
  27. optimizer=Adam(lr=0.0001, decay=1e-6),
  28. metrics=['accuracy'])
  29.  
  30. model.fit(np.array(X_train),np.array(Y_train)
  31. batch_size=batch_size,
  32. shuffle=True,
  33. epochs=nb_epochs,
  34. validation_data=(np.array(X_test),np.array(Y_test)),
  35. callbacks=[EarlyStopping(min_delta=0.00025, patience=2)])
  36.  
  37. Y_train[i, :] = [1.0, 0.0] ##for negative tweets with 0 label in corpus.(and the same for 1,2)
Add Comment
Please, Sign In to add comment