Closed Dongsheng600 closed 3 years ago
While this issue was closed, I'd like to keep a comment for future readers as I was confused exactly at the same place.
The parameter W isn't used in loss_W or it doesn't look meaningfull. However, numerical_gradient() can still use the second parameter to calculate f(x+h) and f(x-h). The trick is the second parameter such as self.param['W1'] is modified "in place" within numerical_gradient() and it changes the self.params['W1'] state. So it eventually affects the value of self.loss(x, t).
Here is the part of codes about my question:
In ch04/two_layer_net.py
In common/gradient.py
I'm not sure about whether the parameter W defined in the lambda function loss_W is meaningful. How will the f(x) in numerical_gradient() in gradient.py work? I think it will not affect the value of the loss function.