Skip to content

Commit

Permalink
動作確認2024
Browse files Browse the repository at this point in the history
  • Loading branch information
taroyabuki committed Mar 24, 2024
1 parent 23e046f commit d177a56
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 32 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Python|Google Colab|[![Open in Colab](https://colab.research.google.com/assets/c
Python|Jupyter|[python.ipynb](code/python.ipynb)|[python-results.ipynb](code/python-results.ipynb)
Python|R Markdown|[python.Rmd](code/python.Rmd)|[python.html](https://taroyabuki.github.io/fromzero/python.html)

コードの使い方は,2.6節を参照してください.
コードの使い方は,2.6節を参照してください[^1]

[^1]: [Amazon SageMaker Studio Lab](addendum/sagemaker)での動作も確認済みです.

## Docker

Expand Down
4 changes: 2 additions & 2 deletions addendum/sagemaker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Amazon SageMaker Studio Lab

無料の[Amazon SageMaker Studio Lab](https://studiolab.sagemaker.aws/)(以下,Studio Lab)で本書のコードを動かすための環境を作ります(GPU動作確認済).Studio Labの概要は,[Amazon SageMaker Studio Lab入門](https://atmarkit.itmedia.co.jp/ait/subtop/features/di/sagemakerstudiolab_index.html)を参照してください.
無料の[Amazon SageMaker Studio Lab](https://studiolab.sagemaker.aws/)(以下,Studio Lab)で本書のコードを動かすための環境を作ります.Studio Labの概要は,[Amazon SageMaker Studio Lab入門](https://atmarkit.itmedia.co.jp/ait/subtop/features/di/sagemakerstudiolab_index.html)を参照してください.

TerminalでGitHubリポジトリをクローンします.

Expand All @@ -22,7 +22,7 @@ conda env create --file fromzero/addendum/sagemaker/sage-python.yml

画面左のファイルブラウザーがあります.

Rのためのノートブックは[fromzero/code/R-notebook](/code/R-notebook),Pythonのためのノードブックは[fromzero/code/Python-notebook](/code/Python-notebook)にあります.
Rのためのノートブックはfromzero/code/r.ipynb(全体)やfromzero/code/R-notebook(各章ごと),Pythonのためのノードブックはfromzero/code/python.ipynb(全体)やfromzero/code/Python-notebook(各章ごと)にあります.

ノートブックのファイル(.ipynb)をダブルクリックするとカーネル選択のダイアログが出るので,Rの場合はsage-r:R,Pythonの場合はsage-python:Pythonを選択してください.

Expand Down
3 changes: 1 addition & 2 deletions code/R-notebook/ch03/03-colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@
"x * y\n",
"#> [1] 6\n",
"\n",
"library(keras)\n",
"c(x, y) %<-% c(20, 30) # まとめて名付け\n",
"keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け\n",
"x * y\n",
"#> [1] 600"
]
Expand Down
3 changes: 1 addition & 2 deletions code/R-notebook/ch03/03.01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
"x * y\n",
"#> [1] 6\n",
"\n",
"library(keras)\n",
"c(x, y) %<-% c(20, 30) # まとめて名付け\n",
"keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け\n",
"x * y\n",
"#> [1] 600"
]
Expand Down
3 changes: 1 addition & 2 deletions code/R-notebook/ch03/03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@
"x * y\n",
"#> [1] 6\n",
"\n",
"library(keras)\n",
"c(x, y) %<-% c(20, 30) # まとめて名付け\n",
"keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け\n",
"x * y\n",
"#> [1] 600"
]
Expand Down
4 changes: 2 additions & 2 deletions code/R-notebook/ch11/11-colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
"source": [
"library(keras)\n",
"library(tidyverse)\n",
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()"
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())"
]
},
{
Expand Down Expand Up @@ -835,7 +835,7 @@
"metadata": {},
"outputs": [],
"source": [
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()\n",
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())\n",
"my_index <- sample(1:60000, 6000)\n",
"x_train <- x_train[my_index, , ]\n",
"y_train <- y_train[my_index]"
Expand Down
2 changes: 1 addition & 1 deletion code/R-notebook/ch11/11.03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"source": [
"library(keras)\n",
"library(tidyverse)\n",
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()"
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion code/R-notebook/ch11/11.04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"metadata": {},
"outputs": [],
"source": [
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()\n",
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())\n",
"my_index <- sample(1:60000, 6000)\n",
"x_train <- x_train[my_index, , ]\n",
"y_train <- y_train[my_index]"
Expand Down
4 changes: 2 additions & 2 deletions code/R-notebook/ch11/11.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
"source": [
"library(keras)\n",
"library(tidyverse)\n",
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()"
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())"
]
},
{
Expand Down Expand Up @@ -804,7 +804,7 @@
"metadata": {},
"outputs": [],
"source": [
"c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()\n",
"keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())\n",
"my_index <- sample(1:60000, 6000)\n",
"x_train <- x_train[my_index, , ]\n",
"y_train <- y_train[my_index]"
Expand Down
3 changes: 1 addition & 2 deletions code/R/ch03/03.01.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ y <- 3
x * y
#> [1] 6

library(keras)
c(x, y) %<-% c(20, 30) # まとめて名付け
keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け
x * y
#> [1] 600

Expand Down
3 changes: 1 addition & 2 deletions code/R/ch03/03.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ y <- 3
x * y
#> [1] 6

library(keras)
c(x, y) %<-% c(20, 30) # まとめて名付け
keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け
x * y
#> [1] 600

Expand Down
2 changes: 1 addition & 1 deletion code/R/ch11/11.03.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

library(keras)
library(tidyverse)
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())

dim(x_train)
#> [1] 60000 28 28
Expand Down
2 changes: 1 addition & 1 deletion code/R/ch11/11.04.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ plot(y, y_)

### 11.4.4 AutoMLによる分類

c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
my_index <- sample(1:60000, 6000)
x_train <- x_train[my_index, , ]
y_train <- y_train[my_index]
Expand Down
4 changes: 2 additions & 2 deletions code/R/ch11/11.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ c(mean(as.array(loss_sparse_categorical_crossentropy(y_true = y, y_pred = y_1)))

library(keras)
library(tidyverse)
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())

dim(x_train)
#> [1] 60000 28 28
Expand Down Expand Up @@ -372,7 +372,7 @@ plot(y, y_)

### 11.4.4 AutoMLによる分類

c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
my_index <- sample(1:60000, 6000)
x_train <- x_train[my_index, , ]
y_train <- y_train[my_index]
Expand Down
3 changes: 1 addition & 2 deletions code/Rmd/ch03/03.01.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ y <- 3
x * y
#> [1] 6
library(keras)
c(x, y) %<-% c(20, 30) # まとめて名付け
keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け
x * y
#> [1] 600
```
Expand Down
3 changes: 1 addition & 2 deletions code/Rmd/ch03/03.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ y <- 3
x * y
#> [1] 6
library(keras)
c(x, y) %<-% c(20, 30) # まとめて名付け
keras::`%<-%`(c(x, y), c(20, 30)) # まとめて名付け
x * y
#> [1] 600
```
Expand Down
2 changes: 1 addition & 1 deletion code/Rmd/ch11/11.03.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```{r}
library(keras)
library(tidyverse)
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
```

```{r}
Expand Down
2 changes: 1 addition & 1 deletion code/Rmd/ch11/11.04.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ plot(y, y_)
### 11.4.4 AutoMLによる分類

```{r}
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
my_index <- sample(1:60000, 6000)
x_train <- x_train[my_index, , ]
y_train <- y_train[my_index]
Expand Down
4 changes: 2 additions & 2 deletions code/Rmd/ch11/11.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ c(mean(as.array(loss_sparse_categorical_crossentropy(y_true = y, y_pred = y_1)))
```{r}
library(keras)
library(tidyverse)
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
```

```{r}
Expand Down Expand Up @@ -478,7 +478,7 @@ plot(y, y_)
### 11.4.4 AutoMLによる分類

```{r}
c(c(x_train, y_train), c(x_test, y_test)) %<-% dataset_mnist()
keras::`%<-%`(c(c(x_train, y_train), c(x_test, y_test)), dataset_mnist())
my_index <- sample(1:60000, 6000)
x_train <- x_train[my_index, , ]
y_train <- y_train[my_index]
Expand Down
6 changes: 5 additions & 1 deletion update.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
p. 6|Windows 11には,脚註4で紹介しているWindows Terminalが搭載されています.
p. 20|[Amazon SageMaker Studio Lab](addendum/sagemaker)での動作も確認済みです.表2.1のクラウド・ノートブックに相当します.
p. 22 脚註3|Google Colabでノートブックを新規作成した後で,ランタイム→ランタイムのタイプを変更で,Rを選択できるようになりました.
p. 56|Rのコード`左辺 %<-% 右辺`が正しく動作しない場合は,``keras::`%<-%`(左辺, 右辺)``に変更してください.配布しているコードはそのように修正しています.
p. 151|GitHub上でのCSVファイルの表示方法が変更されたので,https://github.com/taroyabuki/fromzero/blob/master/data/exam.csv の代わりにhttps://taroyabuki.github.io/fromzero/exam.html を使ってください.
p. 160, 161|scikit-learnのバージョンによっては,Pythonのコードの`get_feature_names()``get_feature_names_out()`に変更する必要があります.配布しているコードはそのように修正しています.
p. 184|[予測値の期待値の信頼区間](addendum/07.03.02/)
Expand All @@ -15,16 +16,19 @@ p. 271, 275|XGBoostで`ValueError: Invalid classes inferred from unique values o
p. 271, 275|9.4.2, 9.5.3項のPythonのコードで警告がたくさん出る場合は,`warnings.simplefilter`の引数の「`, UserWarning`」を削除してみてください.配布しているコードはそのように修正しています.
p. 277|9.6.2項のPythonのコードで警告がたくさん出る場合は,`MLPClassifier()``MLPClassifier(max_iter=1000)`に変更してみてください.配布しているコードはそのように修正しています.
p. 292, 298|scikit-learnのバージョンによっては,Pythonのコードの`get_feature_names()``get_feature_names_out()`に変更する必要があります.配布しているコードはそのように修正しています.
p. 310, 329|Rのコード`左辺 %<-% 右辺`が正しく動作しない場合は,``keras::`%<-%`(左辺, 右辺)``に変更してください.配布しているコードはそのように修正しています.
p. 342|Pythonのコードの`from fbprophet import Prophet``from prophet import Prophet`に変更する必要がある場合があります.配布しているコードでは有効な方を使うように修正しています.

## 正誤表

次の誤りは第5刷で修正しました.

場所|誤|正
--|--|--
p. 258 本文3行目|グラフの中で|連結グラフ(任意の2点を線をつないで結べるグラフ)の中で
p. 351 Pythonのコード|`vals, vecs = np.linalg.eig(S) # 固有値と固有ベクトル`|`vals, vecs = np.linalg.eig(S) # 固有値と固有ベクトル`<br>`idx = np.argsort(-vals) # 固有値の大きい順の番号`<br>`vals, vecs = vals[idx], vecs[:, idx] # 固有値の大きい順での並べ替え`

以下の誤りは第4刷で修正しました
次の誤りは第4刷で修正しました

場所|誤|正
--|--|--
Expand Down

0 comments on commit d177a56

Please sign in to comment.