Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. # define LSTM model
  2. model = Sequential()
  3.  
  4. # Input shape: (samples, time, channels, rows, cols) see: https://keras.io/layers/recurrent/#convlstm2d
  5. model.add(Conv2D(
  6. filters=50,
  7. kernel_size=(5, 5),
  8. input_shape=(120, 40, 1),
  9. padding='same', kernel_initializer='TruncatedNormal'))
  10. model.add(LeakyReLU())
  11. model.add(BatchNormalization()) # Normalizes the data
  12. model.add(Dropout(0.2))
  13. print('L1 Output: ' , model.output_shape)
  14.  
  15. model.add(Conv2D(
  16. filters=25,
  17. kernel_size=(3, 3),
  18. input_shape=(120, 40, 1),
  19. padding='same', kernel_initializer='TruncatedNormal'))
  20. model.add(LeakyReLU())
  21. model.add(BatchNormalization())
  22. model.add(Dropout(0.2))
  23. print('L2 Output: ' , model.output_shape)
  24.  
  25. model.add(Conv2D(
  26. filters=10,
  27. kernel_size=(1, 1),
  28. input_shape=(120, 40, 1),
  29. padding='same', kernel_initializer='TruncatedNormal'))
  30. model.add(LeakyReLU())
  31. model.add(BatchNormalization())
  32. model.add(Dropout(0.2))
  33. print('L3 Output: ' , model.output_shape)
  34.  
  35. model.add(Reshape((120, 10*40)))
  36. print('Reshape Output: ' , model.output_shape)
  37.  
  38. # Input should be: (batch_size, timesteps, input_dim)
  39. model.add(GRU(10, return_sequences=False, activation='sigmoid'))
  40. model.add(Dropout(0.2))
  41. print('LSTM Output: ' , model.output_shape)
  42.  
  43. #model.add(Flatten())
  44. #print('Flatten Output: ' , model.output_shape)
  45.  
  46. model.add(Dense(10))
  47. model.add(LeakyReLU())
  48. model.add(Dropout(0.2))
  49. print('Dense(10) Output: ' , model.output_shape)
  50.  
  51. model.add(Dense(units=output_dim, kernel_initializer='TruncatedNormal'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement