-
Notifications
You must be signed in to change notification settings - Fork 990
02 - Variable.py Bias vector dimension error and python style #27
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
Conversation
sess을 직접 열고 닫는 것보다 with을 활용해서 하는 것이 파이선 코딩 스타일에 더 맞는 것 같습니다. 참고: https://google.github.io/styleguide/pyguide.html Files and Sockets 섹션
X의 차원은 ? * 3 이고 W의 차원은 3 * 2 이기 때문에 X * W의 차원은 ? * 2 가 됩니다. bias는 X * W의 각 행에 더해져야 하기 때문에 b의 차원은 1 * 2 이어야 합니다.
Explicit expression of dimension. Use format instead of % for print
It's the first sample so I don't use with
keyword for making more simple.
And there is no error /w bias 2x1
dimension.
Thanks for your feedback.
bias should be 1 x 2 dimension
Let's say X has dimension 4 x 3
Since W has dimension 3 x 2, matmul(X, W) will have dimension 4 * 2
If b has dimension 2 * 1, matmul(X, W) + b cannot mathematically work.
If b has dimension 1 * 2, matmul(X, W) + b outputs 4 * 2, which is exactly what we want.
Because your example uses X that has dimension 2 * 3, your current code seems to work well (as it coincidentally fit nicely with current b dimension), but you should try the code with X that has dimension 4 * 3. Then you will realize that the code doesn't work because of wrong b dimension.
@NonInertialFrame I got it what you mean. I'll fix it. Thanks!
There is an error in bias dimension and I think using with when creating tf session is better.