Save/load a keras model with constants
问题 I have a Keras model where I'd like to add a constant to the predictions. After some googling, I've ended up with the following code, which does exactly what I want: import numpy as np from keras.layers import Input, Add from keras.backend import variable from keras.models import Model, load_model inputs = Input(shape=(1,)) add_in = Input(tensor=variable([[5]]), name='add') output = Add()([inputs, add_in]) model = Model([inputs, add_in], output) model.compile(loss='mse', optimizer='adam') X =