You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can not figure out how to save the model and reload it wit the same performance as it had when i trained the model
Can someone comment on how i might save this and then reload it i? I feel like it should be more straightforward than it is.
CODE:
Ensure inducing points have the correct dimensions
num_inducing = 2500
inducing_variable = gpflow.inducing_variables.InducingPoints(np.random.randn(num_inducing, 62)) # Match the dense layer output
I can not figure out how to save the model and reload it wit the same performance as it had when i trained the model
Can someone comment on how i might save this and then reload it i? I feel like it should be more straightforward than it is.
CODE:
Ensure inducing points have the correct dimensions
num_inducing = 2500
inducing_variable = gpflow.inducing_variables.InducingPoints(np.random.randn(num_inducing, 62)) # Match the dense layer output
Define kernel
kernel = gpflow.kernels.SquaredExponential()*gpflow.kernels.White(variance=0.01) + gpflow.kernels.White(variance=0.01)
Define likelihood
likelihood = gpflow.likelihoods.Gaussian(0.01)
likelihood_container = gpflux.layers.TrackableLayer()
likelihood_container.likelihood = likelihood
Hybrid model with explicit layer names
gp_hybrid_model = tf.keras.Sequential([
tf.keras.layers.Dense(156, activation="relu", kernel_initializer='he_normal', bias_initializer='he_normal', name="dense_gp_hybrid_1"),
tf.keras.layers.Dropout(0.35),
tf.keras.layers.Dense(62, activation="relu", kernel_initializer='he_normal', bias_initializer='he_normal', name="dense_gp_hybrid_2"),
gpflux.layers.GPLayer(
kernel=kernel,
inducing_variable=inducing_variable,
num_data=X_train.shape[0],
num_latent_gps=31,
mean_function=gpflow.mean_functions.Zero(),
name="gp_layer"
),
likelihood_container
])
Build the model to initialize the layers
gp_hybrid_model.build(input_shape=(None, 78))
The text was updated successfully, but these errors were encountered: