SBクリエイティブ

正誤情報

はじめてのディープラーニング2 正誤情報

2020.04.20
対象書籍
はじめてのディープラーニング2

初版

●P34の辞書の操作

誤)
——————————–
a[“Pinapple”] = 6
print(a[“Pinapple”])
——————————–
正)
——————————–
a[“Pineapple”] = 6
print(a[“Pineapple”])
——————————–

●P39の上から2行目
誤) 4×3
正) 4×3

●P43下のlinspace関数を使う
誤)
——————————–
pprint(np.linspace(0, 1, 11))
——————————–
正)
——————————–
print(np.linspace(0, 1, 11))
——————————–

●P45中盤の1次元配列に変換
誤)
——————————–
e = d.reshape(-1)
——————————–
正)
——————————–
e = c.reshape(-1)
——————————–

●P89 上段のコード

誤)

——————————–

import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets

n_img = 10 # 表示する画像の数
plt.figure(figsize=(10, 4))
for i in range(n_img):
# 入力画像
ax = plt.subplot(2, 5, i+1)
plt.imshow(digits_data.data[i].reshape(8, 8), cmap=”Greys_r”)
ax.get_xaxis().set_visible(False) # 軸を非表示に
ax.get_yaxis().set_visible(False)
plt.show()
print(“データの形状:”, digits_data.data.shape)
print(“ラベル:”, digits_data.target[:n_img])

——————————–

正)

——————————–

import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets

digits_data = datasets.load_digits()

n_img = 10  # 表示する画像の数
plt.figure(figsize=(10, 4))
for i in range(n_img):
# 入力画像
ax = plt.subplot(2, 5, i+1)
plt.imshow(digits_data.data[i].reshape(8, 8), cmap=”Greys_r”)
ax.get_xaxis().set_visible(False)  # 軸を非表示に
ax.get_yaxis().set_visible(False)
plt.show()

print(“データの形状:”, digits_data.data.shape)
print(“ラベル:”, digits_data.target[:n_img])

——————————–

●P146のy^(t)
誤) tan
正) tanh

●P201 リストの「xの勾配」部分
誤)
——————————–

self.grad_x = np.dot(delta_a0, self.w[0].T)
+ np.dot(delta_a1, self.w[1].T)
+ np.dot(delta_a2, self.w[2].T)

——————————–

正)
——————————–

self.grad_x = np.dot(delta_a0, self.w[0].T) \
+ np.dot(delta_a1, self.w[1].T) \
+ np.dot(delta_a2, self.w[2].T)

——————————–

●P202 リストの「y_prevの勾配」部分
誤)
——————————–

self.grad_y_prev = np.dot(delta_a0, self.v[0].T)
+ np.dot(delta_a1, self.v[1].T)
+ a1*s + grad_y*(1-a0)

——————————–

正)
——————————–

self.grad_y_prev = np.dot(delta_a0, self.v[0].T) \
+ np.dot(delta_a1, self.v[1].T) \
+ a1*s + grad_y*(1-a0)

——————————–

●P213 リストの「xの勾配」「y_prevの勾配」部分
誤)
——————————–

# xの勾配
self.grad_x = np.dot(delta_a0, self.w[0].T)
+ np.dot(delta_a1, self.w[1].T)
+ np.dot(delta_a2, self.w[2].T)

# y_prevの勾配
self.grad_y_prev = np.dot(delta_a0, self.v[0].T)
+ np.dot(delta_a1, self.v[1].T)
+ a1*s + grad_y*(1-a0)

——————————–

正)
——————————–

# xの勾配
self.grad_x = np.dot(delta_a0, self.w[0].T) \
+ np.dot(delta_a1, self.w[1].T) \
+ np.dot(delta_a2, self.w[2].T)

# y_prevの勾配
self.grad_y_prev = np.dot(delta_a0, self.v[0].T) \
+ np.dot(delta_a1, self.v[1].T) \
+ a1*s + grad_y*(1-a0)

——————————–

 

この記事をシェアする