{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import torch\n", "from torch import tensor\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from torch.distributions.normal import Normal\n", "from torch.distributions.gamma import Gamma\n", "from torch.distributions.multivariate_normal import MultivariateNormal as MN\n", "from torch.distributions.uniform import Uniform\n", "from scipy.special import gamma as gf\n", "\n", "\"\"\"\n", "BCS Computational Tutorial: Bayesian inference in generative models\n", "Luke Hewitt & Maddie Cusimano // 2018-11-13 \n", "\n", "In this tutorial, we write several different inference methods for a simple Bayesian linear regression model. \n", "\n", "1. Defining the generative model\n", "2. Exact posterior inference\n", "3. Markov Chain Monte Carlo using Metropolis Hastings\n", "4. Classic variational inference using a mean-field approximation\n", "5. Stochastic variational inference\n", " \n", "\"\"\"\n", "print('hello!')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "1. Defining the generative model \n", "\n", "> Prior p(lambda)p(beta | lambda)\n", "tau ~ Gamma(a_0, b_0) # Precision\n", "beta_k ~ Normal(m_0, 1/tau**0.5) # Coefficient for x^k\n", "> Likelihood p(y | beta, x, tau)\n", "y ~ Normal(beta.T x, 1/tau*I)\n", "\n", "more details: https://en.wikipedia.org/wiki/Bayesian_linear_regression\n", "\"\"\"\n", "\n", "print('~~~Defining priors~~~')\n", "def tau_prior(a_0, b_0):\n", " \"\"\"\n", " Prior over the precision, i.e., tau = 1/sigma^2 \n", " \n", " To sample variance:\n", " variance = 1./tau_prior(a_0, b_0).sample()\n", " \"\"\"\n", " return Gamma(a_0, b_0)\n", "\n", "def betas_prior(mu_0, variance):\n", " \"\"\"\n", " Prior over polynomial weights\n", " \n", " To sample k beta weights:\n", " betas = betas_prior(mu_0, variance).sample(sample_shape=torch.Size([k]))\n", " \n", " If comparing to wikipedia, here we've set lambda_0 = 1.0\n", " \"\"\"\n", " return Normal(mu_0, 1e-7 + variance**0.5)\n", "\n", "print('~~~Defining likelihood~~~')\n", "def loglikelihood(y, b, x, variance):\n", " \"\"\"\n", " p(y | b, x, sigma^2) = N(y | mu = f(b,x), sigma^2)\n", " \n", " Inputs\n", " ------\n", " y: (n,) tensor \n", " b: (k,) tensor of weights\n", " x: (n,k) input features\n", " variance: scalar \n", " \n", " Output\n", " ------\n", " Log probability of y's\n", " \n", " \"\"\"\n", " return MN(x.mm(b[:,None]),(1e-7 + variance)*torch.eye(len(y))).log_prob(y)\n", "\n", "def features(_x, k):\n", " \"\"\"\n", " Creates polynomial input features\n", " \n", " Input\n", " -----\n", " _x: (n,) vector of x-coordinates\n", " k: order of polynomial\n", " \n", " Output\n", " ------\n", " x: (n, k) tensor\n", " \"\"\"\n", " x = torch.ones(len(_x), 1)\n", " for i in range(1,k):\n", " feature = _x**i \n", " x = torch.cat((x, feature[:, None]), 1)\n", " return x" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def sample_from_prior(x, a_0, b_0, mu_0, k):\n", " \"\"\"Returns sample of y's given x-coordinates and prior params\"\"\"\n", " x = features(x, k)\n", " variance = 1./tau_prior(a_0, b_0).sample()\n", " betas = betas_prior(mu_0, variance).sample(sample_shape=torch.Size([k]))\n", " y = Normal(x.mm(betas[:, None]), variance**0.5).sample()\n", " return y, betas\n", "\n", "##Sample from the prior \n", "print('~~~Sampling from the prior~~~')\n", "x_list = [-2 + i*0.1 for i in range(41)]; x = tensor(x_list); x_arr = np.array(x_list)\n", "a_0 = tensor(0.5); b_0 = tensor(0.5); mu_0=tensor(0.); k=4;\n", "y, betas = sample_from_prior(x, a_0, b_0, mu_0, k)\n", "polynomial_str = ''\n", "for i, b in enumerate(betas.numpy()):\n", " polynomial_str += '{0:.2f}'.format(b) + 'x^' + str(i) \n", " if i < k - 1: polynomial_str += ' + '\n", "plt.scatter(x_arr, y.numpy()); plt.title(polynomial_str); plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "2. Exact posterior inference\n", "\n", "Since we are using conjugate priors, it is possible to compute the posterior analytically.\n", "The form of the posterior will be the same as the prior: \n", "- Gaussian distribution over betas\n", "- Gamma distribution over precision\n", "\n", "You can find the derivation on the wikipedia page.\n", "\n", "\"\"\"\n", "print('~~~Defining the posterior~~~')\n", "def analytical_posterior(y, x, a_0, b_0, mu_0, k):\n", " \"\"\"\n", " Given a dataset (x,y), return posterior parameters \n", " for p(b | sigma^2, y, x) and p(precision | y, x).\n", " \n", " Inputs\n", " ------\n", " y: (n,) tensor \n", " x: (n,) x-coordinates\n", " a_0, b_0, mu_0: prior parameters\n", " k: order of polynomial \n", " \n", " Outputs\n", " -------\n", " a_posterior: () shape parameter for Gamma dist\n", " b_posterior: () scale parameter for Gamma dist\n", " mu_posterior: (k,) mean\n", " lambda_posterior: (k,k) precision matrix\n", " \n", " \"\"\"\n", " \n", " x = features(x, k)\n", " \n", " ##p(b|tau, y, x) = N(mu_posterior, (1/tau)*lambda_posterior^-1)\n", " XTX = x.t().mm(x)\n", " lambda_0 = torch.eye(k)\n", " lambda_posterior = XTX + lambda_0\n", " lambda_inv = lambda_posterior.inverse()\n", " \n", " mu_0 = mu_0*torch.ones(k,1)\n", " inside = lambda_0.mm(mu_0) + x.t().mm(y)\n", " mu_posterior = lambda_inv.mm(inside)\n", " \n", " ##p(tau| y, X)\n", " a_posterior = a_0 + len(y)/2.\n", " mlm = mu_0.t().mm(lambda_0).mm(mu_0) - mu_posterior.t().mm(lambda_posterior).mm(mu_posterior)\n", " b_posterior = b_0 + 0.5*(y.t().mm(y) + mlm)\n", " \n", " return a_posterior, b_posterior, mu_posterior, lambda_posterior" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def polynomial(bs, x):\n", " m = np.zeros(len(x))\n", " for i, b in enumerate(bs):\n", " m += b*(x**i)\n", " return m\n", "\n", "def sample_from_posterior(x, a, b, mu, lmbda):\n", " variance = 1./Gamma(a, b).sample()\n", " betas = MN(mu.squeeze(), variance*lmbda.inverse()).sample()\n", " return polynomial(betas.numpy(), x)\n", " \n", "##Inference given sampled y\n", "inferred_a, inferred_b, inferred_mu, inferred_lambda = analytical_posterior(y, x, a_0, a_0, mu_0, k)\n", "print('Inferred a: ', inferred_a.numpy())\n", "print('Inferred b: ', inferred_b.squeeze().numpy())\n", "analytical_inferred_mu = inferred_mu.squeeze().numpy();\n", "print('Inferred mu: ', analytical_inferred_mu); \n", "print('Inferred precision (note dependence between betas): ')\n", "print(inferred_lambda.numpy()) \n", "\n", "print('How do samples from the posterior look compared to the data?')\n", "plt.scatter(x_arr, y.numpy()); plt.title('Actual: ' + polynomial_str); \n", "for i in range(100):\n", " plt.plot(x_arr,sample_from_posterior(x, inferred_a, \n", " inferred_b, inferred_mu, inferred_lambda), alpha=0.02, color='blue')\n", "plt.xlim(min(x_list),max(x_list))\n", "plt.show()\n", "\n", "print('We can also check predictions outside of the range of our dataset:')\n", "x_list_extr = [-3 + i*0.1 for i in range(61)]; x_extr = tensor(x_list_extr);\n", "plt.scatter(x_arr, y.numpy());\n", "for i in range(100):\n", " plt.plot(x_list_extr,sample_from_posterior(x_extr, inferred_a, \n", " inferred_b, inferred_mu, inferred_lambda), alpha=0.02, color='blue')\n", "plt.xlim(min(x_list_extr),max(x_list_extr))\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "3. Markov Chain Monte Carlo using Metropolis Hastings\n", "\n", "First we'll define a function to make proposals and \n", "calculate necessary probabilities, given approximate distributions\n", "Then we'll fill out the specifics of our MH algorithm \n", "\n", "\"\"\"\n", "\n", "def propose(transition_dist, prior, prev_val):\n", " \"\"\"\n", " General purpose proposal function\n", " \n", " Inputs\n", " ------\n", " prev_val: the previous sample, z\n", " transition_dist: a function that takes in a val and returns a distribution --> q(z | val)\n", " prior: the prior over val --> p(z)\n", " \n", " Outputs\n", " -------\n", " new_val: new proposed value, z'\n", " prior_logprob: log probability of new_val under its prior p\n", " ft_logprob: transition probability from prev_val to new_val --> log q(z'|z)\n", " bt_logprob: transition probability from new_val to prev_val --> log q(z|z')\n", " \n", " \"\"\"\n", " \n", " # TO DO\n", " # Helpful Syntax--\n", " # To take a sample: dist.sample()\n", " # To get the log probability of val under dist: dist.log_prob(val) \n", " \n", " return new_val, prior_logprob, ft_logprob, bt_logprob " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "To write our MH algorithm, we need to:\n", "\n", "1. Initialize the chain at z_0\n", "2. Define transition distributions q(z'|z)\n", "3. Sample from q(z'|z)\n", "4. Compute the acceptance probability\n", "5. Decide whether to accept the proposal as a sample\n", "\n", "\"\"\"\n", "\n", "def MH(y, x, k, a_0, b_0, mu_0, n_iterations):\n", " \n", " x_features = features(x,k)\n", " \n", " #Define the priors, p(tau) * p(beta | tau)\n", " t_prior = tau_prior(a_0, b_0)\n", " b_prior = lambda variance: betas_prior(mu_0, variance)\n", "\n", " #Storage for samples\n", " tau_samples = []\n", " betas_samples = []\n", " \n", " #Initialize latent variables at prior mean\n", " tau = t_prior.mean\n", " betas = torch.ones(k) * b_prior(1./tau).mean\n", " \n", " for i in range(n_iterations):\n", " \n", " #Calculate the unnormalized posterior (joint pdf) for the previous latents, p(z, x)\n", " tau_logprob = t_prior.log_prob(tau)\n", " betas_logprob = b_prior(1./tau).log_prob(betas)\n", " ll = loglikelihood(y, betas, x_features, 1./tau)\n", " log_p_z_given_x = torch.sum(tau_logprob) + torch.sum(betas_logprob) + torch.sum(ll)\n", " \n", " ##Propose new latent variables \n", " #We will implement a \"single-site\" Metropolis Hastings algorithm\n", " #From iteration to iteration, alternate between proposing a new tau or new betas\n", " if i % 2 == 0:\n", " \n", " def transition_dist(old_tau):\n", " #TO DO: return Q(new_tau | old_tau)\n", " return proposal_dist\n", " tau_prime, tau_logprob, ft_logprob, bt_logprob = propose(transition_dist, t_prior, tau)\n", " betas_prime = betas \n", " betas_logprob = b_prior(1./tau_prime).log_prob(betas_prime) \n", " \n", " else:\n", " tau_prime = tau; \n", " def transition_dist(old_betas):\n", " #TO DO: return Q(new_betas | old_betas)\n", " return proposal_dist\n", " betas_prime, betas_logprob, ft_logprob, bt_logprob = propose(transition_dist, b_prior(1./tau_prime), betas)\n", " \n", " #TO DO: Compute the log likelihood of the new sampled latents \n", " #TO DO: Combine the log probabilities to get the unnormalized posterior for the current latents, p(z', x)\n", " \n", " #TO DO: log ratio = log(p(z', x)) + log q(z' | z) - log(p(z, x)) - log p(z | z')\n", " r = torch.exp(log_ratio).numpy()\n", " \n", " #Decide whether to accept the new latents by the MH algorithm\n", " #TO DO: calculate acceptance probability\n", " u = Uniform(0,1).sample()\n", " if u.numpy() < r:\n", " tau = tau_prime\n", " betas = betas_prime\n", " tau_samples.append(tau.numpy())\n", " betas_samples.append(betas.numpy()) \n", " \n", " return tau_samples, betas_samples" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "Run your MH-MCMC algorithm!\n", "\"\"\"\n", "n_iterations = 3000\n", "tau_samples, betas_samples = MH(y, x, k, a_0, b_0, mu_0, n_iterations)\n", "plt.scatter(x_list, y.numpy()); plt.title('Actual: ' + polynomial_str); \n", "burn_in = 100; lag = 10;\n", "#Plot sampled posterior mean betas \n", "total_samples = 0; \n", "for i in range(burn_in,n_iterations,lag):\n", " b = betas_samples[i] if total_samples == 0 else b + betas_samples[i]\n", " total_samples += 1\n", " plt.plot(x_list_extr,polynomial(betas_samples[i], np.array(x_list_extr)), alpha=0.01, color='blue')\n", "plt.xlim(min(x_list_extr),max(x_list_extr))\n", "print('MCMC (expectation): ')\n", "MCMC_expectation = (b*1./total_samples).tolist()\n", "print(MCMC_expectation)\n", "print('Analytical: ')\n", "print(analytical_inferred_mu)\n", "plt.show() " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "Variational inference\n", "\n", "1. Derive the evidence lower bound\n", "2. Derive updates from the bound\n", "3. Write iterative updates to variational parameters \n", "\n", "\"\"\"\n", "\n", "def elbo_lambda(a, b, a_0, b_0):\n", " #TO DO: Derive and fill in the term of the elbo corresponding to -KL(Q(lambda)||P(lambda))\n", " \n", "def elbo_beta(a, b, nu, omega, mu_0):\n", " # TO DO: Derive and fill in the term of the elbo corresponding to \n", " # E_{tau ~ Q}[-KL(Q(betas)||P(betas|lambda))]\n", "\n", "def elbo_y(a, b, nu, omega, x, y):\n", " p1 = len(y) * 0.5*(torch.digamma(a) - torch.log(b) - torch.log(tensor(2*np.pi)))\n", " p2 = torch.sum(-(a/(2.*b))*(y**2), dim=0)\n", " p3 = torch.sum((a/b)*y.squeeze()*torch.sum(x * nu[None, :], dim=1),dim=0)\n", " p4 = torch.sum(torch.sum( x**2*(1./omega + nu**2)[None, :], dim=1),dim=0)\n", " x_expand = x[:, :, None]\n", " x_expand_T = x[:, None,:]\n", " nu_expand = nu[None, :, None]\n", " nu_expand_T = nu[None, None, :]\n", " t = torch.sum(x_expand*x_expand_T*nu_expand*nu_expand_T,dim=0)\n", " p5 = 2*(t.triu().sum() - t.trace())\n", " p6 = -(a/(2.*b))*(p4 + p5)\n", " return p1 + p2 + p3 + p6\n", "\n", "def compute_elbo(a, b, nu, omega, x, y, a_0, b_0, mu_0):\n", " L = elbo_lambda(a, b, a_0, b_0); \n", " B = elbo_beta(a, b, nu, omega, mu_0);\n", " Y = elbo_y(a, b, nu, omega, x, y);\n", " return L + B + Y" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def update_omega(a, b, x):\n", " #TO DO: return updated omega\n", " \n", "def update_nu_k(a, b, nu, x, y, k):\n", " K = x.size(1)\n", " #TO DO: return updated nu[k]\n", "\n", "def update_b(nu, omega, x, y):\n", " \n", " p1 = tensor(gf(1.5) * 2**(1.5) / np.sqrt(2*np.pi))/omega\n", " p2 = (nu - mu_0)**2\n", " p3 = 0.5*torch.sum(p1 + p2)\n", " \n", " p4 = 0.5*torch.sum(y.squeeze()**2)\n", " \n", " p5 = torch.sum(x * nu[None, :], dim=1)\n", " p6 = -torch.sum(y.squeeze()*p5)\n", " \n", " p7 = torch.sum(x**2*(1./omega + nu**2)[None,:])\n", " t = torch.sum(x[:, :, None]*x[:, None,:]*nu[None, :, None]*nu[None, None, :],dim=0)\n", " p8 = 2*(t.triu().sum() - t.trace())\n", " p9 = 0.5*(p7 + p8)\n", " \n", " return b_0 + p3 + p4 + p6 + p9" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def variational_inference(x, y, a_0, b_0, mu_0, k, n_iterations=10):\n", " \n", " x = features(x,k)\n", " \n", " #We'll check that the elbo increases with each update\n", " elbos = []\n", " \n", " #initialize latent variables\n", " a = (k + 1. + len(y))/2. + a_0 #a does not get updated further\n", " b = b_0\n", " omega = Uniform(0.5, 1.5).sample(sample_shape=torch.Size([k]))\n", " nu = Normal(0,1).sample(sample_shape=torch.Size([k]))\n", " \n", " #start iterative updates\n", " for i in range(n_iterations):\n", " #Update b\n", " #Record the elbo\n", " #Update omega\n", " #Record the elbo\n", " for _k in range(k):\n", " #Update nu[_k]\n", " #Record the elbo\n", "\n", " return omega, nu, elbos" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "Run your 'classic' variational inference\n", "\n", "Check that your elbo is always increasing\n", "\n", "\"\"\"\n", "omega, nu, elbo = variational_inference(x, y, a_0, b_0, mu_0, k)\n", "plt.plot(elbo);plt.title('ELBO by update');plt.show()\n", "plt.scatter(x_list, y.numpy()); plt.title('Actual: ' + polynomial_str); \n", "for i in range(50):\n", " betas = MN(nu, 1e-7 + torch.diag(1./omega)).sample().tolist()\n", " plt.plot(x_list_extr,polynomial(betas, np.array(x_list_extr)), alpha=0.05, color='blue')\n", "plt.xlim(min(x_list_extr),max(x_list_extr))\n", "VI_nu = nu.tolist()\n", "print('VI:')\n", "print(VI_nu)\n", "print('MCMC (expectation): ')\n", "print(MCMC_expectation)\n", "print('Analytical: ')\n", "print(analytical_inferred_mu)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from torch.nn import Parameter\n", "from torch.optim import Adam\n", " \n", "def compute_stochastic_elbo(a, b, nu, omega, x, y, a_0, b_0, mu_0):\n", " \"\"\"\n", " Return a monte-carlo estimate of the ELBO, using a single sample from Q(sigma^-2, beta)\n", " \n", " a, b are the Gamma 'shape' and 'rate' parameters for the variational posterior over *precision*: q(tau) = q(sigma^-2)\n", " nu_k, omega_k are Normal 'mean' and 'precision' parameters for the variational posterior over weights: q(beta_k)\n", " x is an n by k matrix, where each row contains the regression inputs [1, x, x^2, x^3]\n", " y is an n by 1 values\n", " a_0, b_0 the parameters for the Gamma prior over precision P(tau) = P(sigma^-2)\n", " mu_0 is the mean of the Gamma prior on weights beta\n", " \"\"\"\n", " \n", " # Define mean field variational distribution over (beta, tau)\n", " Q_beta = Normal(nu, omega**-0.5)\n", " Q_tau = #TODO\n", " \n", " # Sample from variational distribution: (tau, beta) ~ Q\n", " # Use rsample to make sure that the result is differentiable!\n", " tau = Q_tau.rsample()\n", " sigma = tau**-0.5\n", " beta = Q_beta.rsample()\n", " \n", " # Create a single sample monte-carlo estimate of ELBO\n", " P_tau = #TODO: P(tau)\n", " P_beta = #TODO P(beta | tau)\n", " P_y = #Todo P(y | x, tau, beta)\n", " \n", " kl_tau = #TODO: estimate KL(q(tau) || p(tau))\n", " kl_beta = #TODO: estimate E_{tau~q}[ KL(q(beta)||p(beta|tau)) ]\n", " log_likelihood = #TODO: estimate E_{tau,beta ~ q}[ log p(y | tau, beta, x)]\n", "\n", " elbo = log_likelihood - kl_tau - kl_beta\n", " return elbo\n", "\n", "\n", "def stochastic_gradient_variational_bayes(x, y, a_0, b_0, mu_0, k, n_iterations=20000):\n", " \n", " x = features(x,k)\n", " \n", " #We'll check that the elbo increases with each update\n", " elbos = []\n", " \n", " #initialize latent variables\n", " a = Parameter((k + 1. + len(y))/2. + a_0) #a does not get updated further\n", " b = Parameter(b_0.clone())\n", " omega = Parameter(Uniform(0.5, 1.5).sample(sample_shape=torch.Size([k])))\n", " nu = Parameter(Normal(0,1).sample(sample_shape=torch.Size([k])))\n", " \n", " optimizer = Adam([a, b, omega, nu], lr=1e-3)\n", " #start iterative updates\n", " for i in range(n_iterations):\n", " elbo = compute_stochastic_elbo(a*1, b*1, nu*1, omega*1, x, y, a_0, b_0, mu_0) #*1 is for making a Tensor\n", " elbos.append(elbo.item() if i==0 else 0.9*elbos[-1] + 0.1*elbo.item()) #Keep running average\n", " (-elbo).backward()\n", " optimizer.step()\n", " optimizer.zero_grad()\n", " if i%1000==0: print(\"Iteration\", i, \"ELBO\", elbos[-1])\n", " \n", " return omega, nu, elbos" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", "Run stochastic gradient variational bayes \n", "\"\"\"\n", "omega, nu, elbo = stochastic_gradient_variational_bayes(x, y, a_0, b_0, mu_0, k)\n", "plt.plot(elbo);plt.title('ELBO by update');plt.show()\n", "plt.scatter(x_list, y.numpy()); plt.title('Actual: ' + polynomial_str); \n", "for i in range(50):\n", " betas = MN(nu, 1e-7 + torch.diag(1./omega)).sample().tolist()\n", " plt.plot(x_list_extr,polynomial(betas, np.array(x_list_extr)), alpha=0.05, color='blue')\n", "plt.xlim(min(x_list_extr),max(x_list_extr))\n", "SGVB_nu = nu.tolist()\n", "print('SGVB:')\n", "print(SGVB_nu)\n", "print('VI:')\n", "print(VI_nu)\n", "print('MCMC (expectation): ')\n", "print(MCMC_expectation)\n", "print('Analytical: ')\n", "print(analytical_inferred_mu)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }