fork download
  1. from keras.models import Sequential
  2. from keras.layers import Dense, Activation
  3. import numpy as np
  4.  
  5. model = Sequential([
  6. Dense(5, input_dim=10),
  7. Activation('relu')
  8. ])
  9.  
  10. model2 = Sequential([
  11. Dense(5, input_dim=10, activation='relu')
  12. ])
  13.  
  14. model2.layers[0].set_weights(model.layers[0].get_weights())
  15.  
  16. dummy_data = np.array([[1, 2, 3, -400, 5, 6, 7, -8, -9000, 10]])
  17.  
  18. prediction = model.predict(dummy_data)
  19. prediction2 = model2.predict(dummy_data)
  20.  
  21. print("Prediction:", prediction)
  22. print("Prediction2:", prediction2)
Success #stdin #stdout 3.37s 334616KB
stdin
Standard input is empty
stdout
Prediction: [[1027.4878    0.     1219.1974    0.        0.    ]]
Prediction2: [[1027.4878    0.     1219.1974    0.        0.    ]]