oreilly-japan / deep-learning-from-scratch-3

『ゼロから作る Deep Learning ❸』(O'Reilly Japan, 2020)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variableクラスのmatmulメソッドの設定でmatmaulとtypoしている

ftnext opened this issue · comments

現状

dezero/core.py の 345行目

Variable.matmaul = dezero.functions.matmul

def setup_variable():
    # 省略

    Variable.matmaul = dezero.functions.matmul
    # 省略

影響

ステップ41の例をVariableインスタンスのメソッドで実行しようとすると、
typoが原因で、matmulメソッドの呼び出しでエラーが発生します。
※masterブランチをcloneし、setup.pyを実行して環境構築しています

>>> import numpy as np
>>> from dezero import Variable
>>> x = Variable(np.random.randn(2, 3))
>>> W = Variable(np.random.randn(3, 4))
>>> # y = dezero.functions.matmul(x, W) 相当のコード
>>> y = x.matmul(W)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Variable' object has no attribute 'matmul'
>>> y = x.matmaul(W)
>>> y.shape
(2, 4)

修正

def setup_variable():
    # 省略

    Variable.matmul = dezero.functions.matmul
    # 省略

ありがとうございます。修正しました。
06419d7