Skip to content
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

correct : typo _change_ont_hot_label() -> _change_one_hot_label() #2

Open
wants to merge 2 commits into
base: master
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
3 changes: 2 additions & 1 deletion ch04/gradient_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def tangent_line(f, x):
X = X.flatten()
Y = Y.flatten()

grad = numerical_gradient(function_2, np.array([X, Y]) )
grad = numerical_gradient(function_2, np.array([X, Y]).T)
grad = grad.T

plt.figure()
plt.quiver(X, Y, -grad[0], -grad[1], angles="xy",color="#666666")#,headwidth=10,scale=40,color="#444444")
Expand Down
6 changes: 3 additions & 3 deletions dataset/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def init_mnist():
pickle.dump(dataset, f, -1)
print("Done!")

def _change_ont_hot_label(X):
def _change_one_hot_label(X):
T = np.zeros((X.size, 10))
for idx, row in enumerate(T):
row[X[idx]] = 1
Expand Down Expand Up @@ -114,8 +114,8 @@ def load_mnist(normalize=True, flatten=True, one_hot_label=False):
dataset[key] /= 255.0

if one_hot_label:
dataset['train_label'] = _change_ont_hot_label(dataset['train_label'])
dataset['test_label'] = _change_ont_hot_label(dataset['test_label'])
dataset['train_label'] = _change_one_hot_label(dataset['train_label'])
dataset['test_label'] = _change_one_hot_label(dataset['test_label'])

if not flatten:
for key in ('train_img', 'test_img'):
Expand Down