Skip to content

Commit

Permalink
freeze d2l lib for v1.0.0 release (d2l-ai#2545)
Browse files Browse the repository at this point in the history
* d2l library 1.0.0 release freeze

* CI: disable caching for scratch tests

* Use numpy==1.24.4 for py3.8 support

* Use numpy==1.23.5

* PyTorch: Fix numpy object to float conversion

* MXNet: Fix mxnet arange issue

* CI: enable caching switchback
  • Loading branch information
AnirudhDagar authored Aug 16, 2023
1 parent a3360ed commit 3ba74ec
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
6 changes: 3 additions & 3 deletions chapter_multilayer-perceptrons/kaggle-house-price.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def get_dataloader(self, train):
label = 'SalePrice'
data = self.train if train else self.val
if label not in data: return
get_tensor = lambda x: d2l.tensor(x.values, dtype=d2l.float32)
get_tensor = lambda x: d2l.tensor(x.values.astype(float), dtype=d2l.float32)
# Logarithm of prices
tensors = (get_tensor(data.drop(columns=[label])), # X
d2l.reshape(d2l.log(get_tensor(data[label])), (-1, 1))) # Y
Expand Down Expand Up @@ -403,11 +403,11 @@ The following code will generate a file called `submission.csv`.
```{.python .input}
%%tab all
if tab.selected('pytorch', 'mxnet', 'tensorflow'):
preds = [model(d2l.tensor(data.val.values, dtype=d2l.float32))
preds = [model(d2l.tensor(data.val.values.astype(float), dtype=d2l.float32))
for model in models]
if tab.selected('jax'):
preds = [model.apply({'params': trainer.state.params},
d2l.tensor(data.val.values, dtype=d2l.float32))
d2l.tensor(data.val.values.astype(float), dtype=d2l.float32))
for model in models]
# Taking exponentiation of predictions in the logarithm scale
ensemble_preds = d2l.reduce_mean(d2l.exp(d2l.concat(preds, 1)), 1)
Expand Down
16 changes: 15 additions & 1 deletion chapter_optimization/gd.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,21 @@ def train_2d(trainer, steps=20, f_grad=None): #@save
```

```{.python .input}
#@tab mxnet, tensorflow
#@tab mxnet
def show_trace_2d(f, results): #@save
"""Show the trace of 2D variables during optimization."""
d2l.set_figsize()
d2l.plt.plot(*zip(*results), '-o', color='#ff7f0e')
x1, x2 = d2l.meshgrid(d2l.arange(-55, 1, 1),
d2l.arange(-30, 1, 1))
x1, x2 = x1.asnumpy()*0.1, x2.asnumpy()*0.1
d2l.plt.contour(x1, x2, f(x1, x2), colors='#1f77b4')
d2l.plt.xlabel('x1')
d2l.plt.ylabel('x2')
```

```{.python .input}
#@tab tensorflow
def show_trace_2d(f, results): #@save
"""Show the trace of 2D variables during optimization."""
d2l.set_figsize()
Expand Down
5 changes: 3 additions & 2 deletions d2l/mxnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,9 @@ def show_trace_2d(f, results):
Defined in :numref:`subsec_gd-learningrate`"""
d2l.set_figsize()
d2l.plt.plot(*zip(*results), '-o', color='#ff7f0e')
x1, x2 = d2l.meshgrid(d2l.arange(-5.5, 1.0, 0.1),
d2l.arange(-3.0, 1.0, 0.1))
x1, x2 = d2l.meshgrid(d2l.arange(-55, 1, 1),
d2l.arange(-30, 1, 1))
x1, x2 = x1.asnumpy()*0.1, x2.asnumpy()*0.1
d2l.plt.contour(x1, x2, f(x1, x2), colors='#1f77b4')
d2l.plt.xlabel('x1')
d2l.plt.ylabel('x2')
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import d2l

requirements = [
'jupyter',
'numpy<=1.23.5',
'matplotlib',
'matplotlib-inline',
'requests',
'pandas'
'jupyter==1.0.0',
'numpy==1.23.5',
'matplotlib==3.7.2',
'matplotlib-inline==0.1.6',
'requests==2.31.0',
'pandas==2.0.3'
]

setup(
name='d2l',
version=d2l.__version__,
python_requires='>=3.5',
python_requires='>=3.8',
author='D2L Developers',
author_email='[email protected]',
url='https://d2l.ai',
Expand Down

0 comments on commit 3ba74ec

Please sign in to comment.