jactorch.functional.kernel#
Useful utilities for kernel-based attention mechanism.
Functions
|
Cosine distance kernel. |
|
Dot product kernel, essentially a cosine distance kernel without normalization. |
|
Inverse distance kernel. |
Functions
- cosine_distance(f_lookup, f)[source]#
Cosine distance kernel.
- Parameters:
f_lookup (FloatTensor) – features of the lookup keys
f (FloatTensor) – features of the value keys
- Returns:
the attention mask for each lookup keys.
- Return type:
FloatTensor