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

MeanSquaredErrorクラスについて(step42) #20

Closed
kawase621 opened this issue Jun 13, 2020 · 2 comments
Closed

MeanSquaredErrorクラスについて(step42) #20

kawase621 opened this issue Jun 13, 2020 · 2 comments

Comments

@kawase621
Copy link

p.323のMeanSquaredErrorクラスでは、backwardでgyに対してbroadcast_to関数が実行されていますが、これは必要でしょうか?
その下でgx0が計算される際、gy*diffの部分はmul関数のforwardが呼ばれることになると思いますが、これはndarrayに対して計算が行われるため、gyは自動的に拡張されると思うのですが、どうでしょうか?

@koki0702
Copy link
Collaborator

ご指摘ありがとうございます。
たしかに、 broadcast_to(...) の行は不要ですね。

後ほど修正したいと思います。
ありがとうございます。

@DhoshuT
Copy link

DhoshuT commented Sep 12, 2020

mean_square_error(x0, x1) で x0とx1のshapeが異なる場合、MeanSquaredError のbackward 関数で sum_toを使う必要があるのではないでしょうか。そうでないと x0, x1 と x0.grad, x1.gradの shapeが異なると思うのですが。
(でも実際上、x0とx1のshapeが異なるような想定をする必要はないですね。)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants