Skip to content

FIX: Deprecation and Future Warnings #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lectures/back_prop.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.11.5
jupytext_version: 1.16.7
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand Down Expand Up @@ -595,9 +595,7 @@ Image(fig.to_image(format="png"))

```{code-cell} ipython3
## to check that gpu is activated in environment

from jax.lib import xla_bridge
print(xla_bridge.get_backend().platform)
print(f"JAX backend: {jax.devices()[0].platform}")
```

```{note}
Expand Down
52 changes: 26 additions & 26 deletions lectures/perm_income_cons.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.16.7
kernelspec:
display_name: Python 3
display_name: Python 3 (ipykernel)
language: python
name: python3
---
Expand All @@ -29,10 +31,9 @@ kernelspec:

In addition to what's in Anaconda, this lecture will need the following libraries:

```{code-cell} ipython
---
tags: [hide-output]
---
```{code-cell} ipython3
:tags: [hide-output]

!pip install quantecon
```

Expand Down Expand Up @@ -74,9 +75,8 @@ The model will prove useful for illustrating concepts such as

Let's start with some imports:

```{code-cell} ipython
```{code-cell} ipython3
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
import quantecon as qe
import numpy as np
import scipy.linalg as la
Expand Down Expand Up @@ -329,7 +329,7 @@ In what follows we set it equal to unity.

First, we create the objects for the optimal linear regulator

```{code-cell} python3
```{code-cell} ipython3
# Set parameters
α, β, ρ1, ρ2, σ = 10.0, 0.95, 0.9, 0.0, 1.0

Expand Down Expand Up @@ -364,7 +364,7 @@ sxbewley = sxo

The next step is to create the matrices for the LQ system

```{code-cell} python3
```{code-cell} ipython3
A12 = np.zeros((3,1))
ALQ_l = np.hstack([A, A12])
ALQ_r = np.array([[0, -R, 0, R]])
Expand All @@ -383,7 +383,7 @@ CLQ = np.array([0., σ, 0., 0.]).reshape(4,1)

Let's print these out and have a look at them

```{code-cell} python3
```{code-cell} ipython3
print(f"A = \n {ALQ}")
print(f"B = \n {BLQ}")
print(f"R = \n {RLQ}")
Expand All @@ -392,14 +392,14 @@ print(f"Q = \n {QLQ}")

Now create the appropriate instance of an LQ model

```{code-cell} python3
```{code-cell} ipython3
lqpi = qe.LQ(QLQ, RLQ, ALQ, BLQ, C=CLQ, beta=β_LQ)
```

We'll save the implied optimal policy function soon compare them with what we get by
employing an alternative solution method

```{code-cell} python3
```{code-cell} ipython3
P, F, d = lqpi.stationary_values() # Compute value function and decision rule
ABF = ALQ - BLQ @ F # Form closed loop system
```
Expand Down Expand Up @@ -428,7 +428,7 @@ $$

Now we'll apply the formulas in this system

```{code-cell} python3
```{code-cell} ipython3
# Use the above formulas to create the optimal policies for b_{t+1} and c_t
b_pol = G @ la.inv(np.eye(3, 3) - β * A) @ (A - np.eye(3, 3))
c_pol = (1 - β) * G @ la.inv(np.eye(3, 3) - β * A)
Expand All @@ -453,13 +453,13 @@ G_LSS = np.hstack([G_LSS1, G_LSS2])

`A_LSS` calculated as we have here should equal `ABF` calculated above using the LQ model

```{code-cell} python3
```{code-cell} ipython3
ABF - A_LSS
```

Now compare pertinent elements of `c_pol` and `F`

```{code-cell} python3
```{code-cell} ipython3
print(c_pol, "\n", -F)
```

Expand Down Expand Up @@ -501,7 +501,7 @@ A second graph plots a collection of simulations against the population distrib

Comparing sample paths with population distributions at each date $t$ is a useful exercise---see {ref}`our discussion <lln_mr>` of the laws of large numbers

```{code-cell} python3
```{code-cell} ipython3
lss = qe.LinearStateSpace(A_LSS, C_LSS, G_LSS, mu_0=μ_0, Sigma_0=Σ_0)
```

Expand All @@ -514,7 +514,7 @@ In the code below, we use the [LinearStateSpace](https://github.com/QuantEcon/Qu
- simulate a group of 25 consumers and plot sample paths on the same
graph as the population distribution.

```{code-cell} python3
```{code-cell} ipython3
def income_consumption_debt_series(A, C, G, μ_0, Σ_0, T=150, npaths=25):
"""
This function takes initial conditions (μ_0, Σ_0) and uses the
Expand Down Expand Up @@ -545,8 +545,8 @@ def income_consumption_debt_series(A, C, G, μ_0, Σ_0, T=150, npaths=25):
debt_var = np.empty(T)
for t in range(T):
μ_x, μ_y, Σ_x, Σ_y = next(moment_generator)
cons_mean[t], cons_var[t] = μ_y[1], Σ_y[1, 1]
debt_mean[t], debt_var[t] = μ_x[3], Σ_x[3, 3]
cons_mean[t], cons_var[t] = μ_y[1,0], Σ_y[1, 1]
debt_mean[t], debt_var[t] = μ_x[3,0], Σ_x[3, 3]

return bsim, csim, ysim, cons_mean, cons_var, debt_mean, debt_var

Expand Down Expand Up @@ -622,7 +622,7 @@ def consumption_debt_fanchart(csim, cons_mean, cons_var,

Now let's create figures with initial conditions of zero for $y_0$ and $b_0$

```{code-cell} python3
```{code-cell} ipython3
out = income_consumption_debt_series(A_LSS, C_LSS, G_LSS, μ_0, Σ_0)
bsim0, csim0, ysim0 = out[:3]
cons_mean0, cons_var0, debt_mean0, debt_var0 = out[3:]
Expand All @@ -632,7 +632,7 @@ consumption_income_debt_figure(bsim0, csim0, ysim0)
plt.show()
```

```{code-cell} python3
```{code-cell} ipython3
consumption_debt_fanchart(csim0, cons_mean0, cons_var0,
bsim0, debt_mean0, debt_var0)

Expand Down Expand Up @@ -698,7 +698,7 @@ behavior early in the sample.

By altering initial conditions, we shall remove this transient in our second example to be presented below

```{code-cell} python3
```{code-cell} ipython3
def cointegration_figure(bsim, csim):
"""
Plots the cointegration
Expand All @@ -713,7 +713,7 @@ def cointegration_figure(bsim, csim):
return fig
```

```{code-cell} python3
```{code-cell} ipython3
cointegration_figure(bsim0, csim0)
plt.show()
```
Expand Down Expand Up @@ -756,7 +756,7 @@ There is no need for foreigners to lend to our group.

Let's have a look at the corresponding figures

```{code-cell} python3
```{code-cell} ipython3
out = income_consumption_debt_series(A_LSS, C_LSS, G_LSS, mxbewley, sxbewley)
bsimb, csimb, ysimb = out[:3]
cons_meanb, cons_varb, debt_meanb, debt_varb = out[3:]
Expand All @@ -766,7 +766,7 @@ consumption_income_debt_figure(bsimb, csimb, ysimb)
plt.show()
```

```{code-cell} python3
```{code-cell} ipython3
consumption_debt_fanchart(csimb, cons_meanb, cons_varb,
bsimb, debt_meanb, debt_varb)

Expand All @@ -785,7 +785,7 @@ But now there is some initial dispersion because there is *ex-ante* heterogeneit

Let's have a look at the cointegration figure

```{code-cell} python3
```{code-cell} ipython3
cointegration_figure(bsimb, csimb)
plt.show()
```
10 changes: 9 additions & 1 deletion lectures/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ and the following package versions
!conda list
```

This lecture series also has access to the following GPU
You can check the backend used by JAX using:

```{code-cell} ipython3
import jax
# Check if JAX is using GPU
print(f"JAX backend: {jax.devices()[0].platform}")
```

and this lecture series also has access to the following GPU

```{code-cell} ipython
!nvidia-smi
Expand Down
Loading