Skip to content

Commit acc8051

Browse files
committed
adding tensorfu2
1 parent eb36648 commit acc8051

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/day2/tensorfu2.rst

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Tensor-Fu-2
2+
===========
3+
4+
Exercise 1
5+
----------
6+
7+
.. code-block:: python
8+
9+
indices = torch.arange(10).long()
10+
indices = torch.from_numpy(np.random.randint(0, 10, size=(10,)))
11+
12+
emb = nn.Embedding(num_embeddings=100, embedding_dim=16)
13+
emb(indices)
14+
15+
Task: Get the above code to work.
16+
Use the second indices method and change the size to a matrix (such as (10,11)).
17+
18+
Exercise 2
19+
----------
20+
21+
Task: Create a MultiEmbedding class which can input two sets of indices, embed them, and concat the results!
22+
23+
.. code-block:: python
24+
25+
class MultiEmbedding(nn.Module):
26+
def __init__(self, num_embeddings1, num_embeddings2, embedding_dim1, embedding_dim2):
27+
pass
28+
29+
def forward(self, indices1, indices2):
30+
# use something like
31+
# z = torch.concat([x, y], dim=1)
32+
33+
pass

0 commit comments

Comments
 (0)