Skip to content

Commit

Permalink
Merge pull request #129 from tmu-nlp/okabe_w2
Browse files Browse the repository at this point in the history
add output for  knock72
  • Loading branch information
sane40007 authored Jun 24, 2024
2 parents 66cf5b4 + 7b4beb7 commit 6eda889
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion okabe/chapter08/knock72.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@
net.zero_grad()#gradient reset
loss4.backward()
print(f"id 1~4 CE loss: {loss4}")
print(f"id 1~4 gradient: {net.weight.grad}")
print(f"id 1~4 gradient: {net.weight.grad}")

"""
output:
id 1 CE loss: 1.383530616760254
id 1 gradient: tensor([[-0.0173, 0.0280, 0.0020, ..., 0.0441, -0.0262, -0.0411],
[ 0.0057, -0.0093, -0.0007, ..., -0.0146, 0.0087, 0.0136],
[ 0.0053, -0.0085, -0.0006, ..., -0.0134, 0.0080, 0.0125],
[ 0.0063, -0.0102, -0.0007, ..., -0.0161, 0.0095, 0.0150]])
id 1~4 CE loss: 1.382717251777649
id 1~4 gradient: tensor([[-6.1116e-03, -3.2874e-03, 7.6965e-03, ..., 1.1390e-02,
-1.8714e-02, -1.0351e-02],
[ 1.3105e-03, 1.7909e-03, -3.1221e-03, ..., -6.0536e-03,
6.8856e-03, 3.1020e-03],
[ 3.3788e-03, -9.1946e-05, -1.2998e-03, ..., 1.3072e-03,
4.7228e-03, 3.7497e-03],
[ 1.4223e-03, 1.5884e-03, -3.2746e-03, ..., -6.6438e-03,
7.1055e-03, 3.4992e-03]])
"""

0 comments on commit 6eda889

Please sign in to comment.