{"id":27845,"library":"gpflow","title":"GPflow","description":"GPflow is a Gaussian process library in TensorFlow, designed for GP regression and advanced GP models. It provides a flexible, composable framework for building and training GP models using TensorFlow's automatic differentiation. Current version 2.10.0 targets TensorFlow 2.x and has a moderate release cadence (major/minor roughly every few months).","status":"active","version":"2.10.0","language":"python","source_language":"en","source_url":"https://github.com/GPflow/GPflow","tags":["gaussian-processes","tensorflow","bayesian-machine-learning","probabilistic-programming"],"install":[{"cmd":"pip install gpflow","lang":"bash","label":"Install latest stable"}],"dependencies":[{"reason":"Core backend for GPflow; must be installed separately (TF 2.x).","package":"tensorflow","optional":false},{"reason":"Optional but recommended for certain models and utilities.","package":"tensorflow-probability","optional":true}],"imports":[{"note":"In GPflow 2.x, submodules are not automatically imported; use `from gpflow import kernels` or import explicitly.","wrong":"import gpflow.kernels","symbol":"gpflow.kernels","correct":"from gpflow import kernels"},{"note":"","wrong":"","symbol":"GPR","correct":"from gpflow.models import GPR"},{"note":"","wrong":"","symbol":"SVGP","correct":"from gpflow.models import SVGP"}],"quickstart":{"code":"import gpflow\nimport numpy as np\nimport tensorflow as tf\n\n# Create synthetic data\nX = np.random.randn(20, 1)\nY = np.sin(X) + 0.1 * np.random.randn(20, 1)\n\n# Build model\nk = gpflow.kernels.SquaredExponential()\nm = gpflow.models.GPR(data=(X, Y), kernel=k, noise_variance=1.0)\n\n# Optimise\nopt = gpflow.optimizers.Scipy()\nopt.minimize(m.training_loss, m.trainable_variables)\n\n# Predict\nXtest = np.linspace(-3, 3, 100)[:, None]\nmean, var = m.predict_f(Xtest)\nprint(\"Predictions:\", mean.numpy().flatten()[:5])","lang":"python","description":"Basic GP regression with GPflow: create data, build GPR model with SquaredExponential kernel, optimise hyperparameters, and predict."},"warnings":[{"fix":"Migrate code: use `from gpflow import ...` (not `import gpflow as gp` submodules), replace `gpflow.kernels.RBF` with `gpflow.kernels.SquaredExponential`, and update to TF 2.x.","message":"GPflow 2.x is a major rewrite with breaking changes from 1.x. The API, module structure, and TensorFlow version requirements (TF 2.x) are different. Models built for GPflow 1.x will not work without modification.","severity":"breaking","affected_versions":"1.x -> 2.0+"},{"fix":"Keep TensorFlow updated and pin versions if needed.","message":"GPflow 2.10.0 still supports TensorFlow 2.x, but future versions may require TensorFlow 2.10+ or higher. Check compatibility matrix.","severity":"deprecated","affected_versions":">=2.0"},{"fix":"Call `m.training_loss.numpy()` to get the value as a float.","message":"When using `gpflow.models.GPR` (or other models), the training loss is a TensorFlow tensor, not a scalar. Use `.numpy()` to get a Python float if needed.","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from gpflow import kernels` instead of `import gpflow.kernels`.","cause":"GPflow 2.x lazy-loads submodules; you must import them explicitly.","error":"AttributeError: module 'gpflow' has no attribute 'kernels'"},{"fix":"Cast input data: `tf.cast(X, tf.float64)` or set global default to float64.","cause":"GPflow defaults to float64; TensorFlow may produce float32 from default settings.","error":"TypeError: Expected float64, got float32"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}