Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. # input layer
  2. input_layer = Input(shape=(28, 28, 1))
  3.  
  4. # encoding architecture
  5. encoded_layer1 = Conv2D(64, (3, 3), activation='relu', padding='same')(input_layer)
  6. encoded_layer1 = MaxPool2D( (2, 2), padding='same')(encoded_layer1)
  7. encoded_layer2 = Conv2D(32, (3, 3), activation='relu', padding='same')(encoded_layer1)
  8. encoded_layer2 = MaxPool2D( (2, 2), padding='same')(encoded_layer2)
  9. encoded_layer3 = Conv2D(16, (3, 3), activation='relu', padding='same')(encoded_layer2)
  10. latent_view = MaxPool2D( (2, 2), padding='same')(encoded_layer3)
  11.  
  12. # decoding architecture
  13. decoded_layer1 = Conv2D(16, (3, 3), activation='relu', padding='same')(latent_view)
  14. decoded_layer1 = UpSampling2D((2, 2))(decoded_layer1)
  15. decoded_layer2 = Conv2D(32, (3, 3), activation='relu', padding='same')(decoded_layer1)
  16. decoded_layer2 = UpSampling2D((2, 2))(decoded_layer2)
  17. decoded_layer3 = Conv2D(64, (3, 3), activation='relu')(decoded_layer2)
  18. decoded_layer3 = UpSampling2D((2, 2))(decoded_layer3)
  19. output_layer = Conv2D(1, (3, 3), padding='same', activation='sigmoid')(decoded_layer3)
  20.  
  21. # compile the model
  22. model = Model(input_layer, output_layer)
  23. model.compile(optimizer='adam', loss='mse')
  24.  
  25. # run the model
  26. early_stopping = EarlyStopping(monitor='val_loss', min_delta=0, patience=10, verbose=5, mode='auto')
  27. history = model.fit(train_x_n, x_train, epochs=20, batch_size=2048, validation_data=(val_x_n, x_test), callbacks=[early_stopping])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement