Guest User

Untitled

a guest
Jan 22nd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #Start with the NN
  2.  
  3. model = tf.keras.Sequential([
  4. tf.keras.layers.Embedding(np.amax(ml_input)+1, 300, input_length = x_train.shape[1]),
  5. tf.keras.layers.Flatten(),
  6. tf.keras.layers.Dense(500, activation=tf.keras.activations.softmax),
  7. tf.keras.layers.Dense(1, activation = tf.keras.activations.linear)
  8. ])
  9.  
  10. model.compile(optimizer=tf.keras.optimizers.Adam(lr=0.01),
  11. loss=tf.keras.losses.mean_absolute_error,
  12. metrics=[R_squared])
  13. model.summary()
  14.  
  15.  
  16.  
  17. #Train the Model
  18. callback = [tf.keras.callbacks.EarlyStopping(monitor='loss', min_delta=5.0, patience=15),
  19. tf.keras.callbacks.ReduceLROnPlateau(monitor='loss', factor=0.1, patience=5, min_delta=5.00, min_lr=0)
  20. ]
  21. history = model.fit(x_train, y_train, epochs=50, batch_size=64, verbose =2, callbacks = callback)
Add Comment
Please, Sign In to add comment