diff --git a/Playgrounds/prova.ipynb b/Playgrounds/prova.ipynb new file mode 100644 index 0000000..a4996bb --- /dev/null +++ b/Playgrounds/prova.ipynb @@ -0,0 +1,41 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "4ae47336", + "metadata": {}, + "outputs": [], + "source": [ + "import torch\n", + "B, T, D = 4, 7, 32\n", + "x = torch.randn(B, T, D)\n", + "attn_mask = torch.triu(torch.ones(T, T, dtype=torch.bool), diagonal=1) # [T,T]\n", + "pad_mask = torch.zeros(B, T, dtype=torch.bool) # no pads\n", + "mha = torch.nn.MultiheadAttention(D, num_heads=4, batch_first=True)\n", + "y, _ = mha(x, x, x, attn_mask=attn_mask, key_padding_mask=pad_mask) # should work\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "deep_learning", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}