I’m stuck in this exercise, I read some forums and I think I applied all the functions correctly. These are the shapes and values of my variable throughout the whole process:
embedding (2, 3, 4) tf.Tensor(
[[[ 0.00860578 0.00740315 -0.0409526 0.00755553]
[ 0.01270969 0.04936013 -0.04764051 -0.04633161]
[-0.02472718 -0.03895496 0.01122528 -0.03709315]]
[[ 0.01270969 0.04936013 -0.04764051 -0.04633161]
[ 0.00860578 0.00740315 -0.0409526 0.00755553]
[ 0.0144151 0.03082472 0.03976548 0.01368902]]], shape=(2, 3, 4), dtype=float32)
square root (2, 3, 4) tf.Tensor(
[[[ 0.01721156 0.01480629 -0.0819052 0.01511107]
[ 0.02541938 0.09872026 -0.09528103 -0.09266322]
[-0.04945436 -0.07790992 0.02245057 -0.0741863 ]]
[[ 0.02541938 0.09872026 -0.09528103 -0.09266322]
[ 0.01721156 0.01480629 -0.0819052 0.01511107]
[ 0.02883019 0.06164945 0.07953096 0.02737803]]], shape=(2, 3, 4), dtype=float32)
position encoding (2, 3, 4) tf.Tensor(
[[[ 0.01721156 1.0148063 -0.0819052 1.0151111 ]
[ 0.8668903 0.6390225 -0.08528119 0.90728676]
[ 0.8598431 -0.49405676 0.04244923 0.9256137 ]]
[[ 0.02541938 1.0987203 -0.09528103 0.9073368 ]
[ 0.8586825 0.55510855 -0.07190537 1.015061 ]
[ 0.9381276 -0.3544974 0.09952962 1.027178 ]]], shape=(2, 3, 4), dtype=float32)
dropout (2, 3, 4) tf.Tensor(
[[[ 0.01912395 1.1275625 -0.09100578 1.1279013 ]
[ 0.9632115 0.7100251 -0.09475689 1.0080965 ]
[ 0.9553812 -0.548952 0.04716581 1.0284597 ]]
[[ 0.02824375 1.2208004 -0.10586781 1.008152 ]
[ 0.9540917 0.6167873 -0.07989486 1.1278456 ]
[ 1.042364 -0.39388603 0.11058848 1.141309 ]]], shape=(2, 3, 4), dtype=float32)
stack of encoding layers (2, 3, 4) tf.Tensor(
[[[-0.8311426 1.1151567 -1.1483109 0.86429673]
[ 0.6521363 -0.16201025 -1.5543296 1.0642036 ]
[ 1.0701332 -1.2811097 -0.6663007 0.8772773 ]]
[[-0.8419315 1.1047187 -1.1404076 0.87762046]
[ 0.6385438 -0.14090931 -1.5619406 1.064306 ]
[ 1.0678458 -1.285623 -0.6602554 0.87803257]]], shape=(2, 3, 4), dtype=float32)
and got the error:
AssertionError: Wrong values case 1
for the sqrt part i used the tf.math.sqrt with tf.cast