standard_lasso
Jonathan corrected a spurious use of standard_lasso
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
---
|
||||
jupyter:
|
||||
jupytext:
|
||||
cell_metadata_filter: -all
|
||||
formats: Rmd,ipynb
|
||||
main_language: python
|
||||
text_representation:
|
||||
extension: .Rmd
|
||||
format_name: rmarkdown
|
||||
format_version: '1.2'
|
||||
jupytext_version: 1.14.7
|
||||
---
|
||||
|
||||
# Chapter 10
|
||||
|
||||
@@ -236,7 +224,7 @@ $\lambda$ with an all-zero solution. This value equals the largest absolute inn
|
||||
X_s = scaler.fit_transform(X_train)
|
||||
n = X_s.shape[0]
|
||||
lam_max = np.fabs(X_s.T.dot(Y_train - Y_train.mean())).max() / n
|
||||
param_grid = {'alpha': np.exp(np.linspace(0, np.log(0.01), 100))
|
||||
param_grid = {'lasso__alpha': np.exp(np.linspace(0, np.log(0.01), 100))
|
||||
* lam_max}
|
||||
```
|
||||
Note that we had to transform the data first, since the scale of the variables impacts the choice of $\lambda$.
|
||||
@@ -246,7 +234,7 @@ We now perform cross-validation using this sequence of $\lambda$ values.
|
||||
cv = KFold(10,
|
||||
shuffle=True,
|
||||
random_state=1)
|
||||
grid = GridSearchCV(lasso,
|
||||
grid = GridSearchCV(standard_lasso,
|
||||
param_grid,
|
||||
cv=cv,
|
||||
scoring='neg_mean_absolute_error')
|
||||
@@ -868,7 +856,7 @@ for idx, (X_ ,Y_) in enumerate(cifar_dm.train_dataloader()):
|
||||
|
||||
|
||||
Before we start, we look at some of the training images; similar code produced
|
||||
Figure 10.5 on page 447. The example below also illustrates
|
||||
Figure 10.5 on page 406. The example below also illustrates
|
||||
that `TensorDataset` objects can be indexed with integers --- we are choosing
|
||||
random images from the training data by indexing `cifar_train`. In order to display correctly,
|
||||
we must reorder the dimensions by a call to `np.transpose()`.
|
||||
@@ -1388,7 +1376,7 @@ We’ll now make a plot to compare our neural network results with the
|
||||
lasso.
|
||||
|
||||
```{python}
|
||||
# %%capture
|
||||
%%capture
|
||||
fig, axes = subplots(1, 2, figsize=(16, 8), sharey=True)
|
||||
for ((X_, Y_),
|
||||
data_,
|
||||
|
||||
177109
Ch10-deeplearning-lab.ipynb
177109
Ch10-deeplearning-lab.ipynb
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user