Hi,
I have different different u, i c variables of shape [99] which contain:
`In [8]: u
Out[8]:
tensor([820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, 820,
820], device='cuda:0')
In [9]: i
Out[9]:
tensor([1280, 2561, 2562, 1029, 1019, 2058, 1550, 1807, 2319, 2067, 2324, 1304,
2331, 1052, 1565, 1308, 2591, 1567, 1314, 1573, 1574, 1066, 2090, 1324,
1329, 2610, 2356, 1589, 1085, 1600, 1856, 1603, 1099, 1101, 1873, 1362,
1107, 1624, 1113, 1114, 2396, 1888, 1633, 1121, 1641, 1643, 1645, 1392,
1906, 2164, 1910, 1403, 1405, 1920, 1921, 1410, 1160, 2187, 2448, 1173,
2456, 2459, 1183, 1184, 1187, 2467, 1192, 1450, 1963, 2481, 2226, 2232,
1722, 2240, 1472, 1984, 1220, 2500, 1483, 1228, 1741, 977, 2260, 2005,
1750, 2522, 2523, 1244, 1505, 2535, 1516, 1773, 1007, 1777, 2289, 1522,
1013, 1016, 1275], device='cuda:0')
In [12]: c
Out[12]:
tensor([2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694,
2694, 2694, 2694], device='cuda:0')`
In order to generate their embeddings I pass to the model the unique idx of all of them so that it computes the corresponding embeddings, following the example, I pass the variable (whose len(unique_uic) == 101) :
`In [32]: unique_uic
Out[32]:
tensor([ 820, 946, 959, 1009, 1010, 1013, 1044, 1109, 1147, 1149, 1152, 1182,
1184, 1208, 1222, 1267, 1308, 1334, 1409, 1417, 1421, 1431, 1455, 1457,
1462, 1470, 1475, 1565, 1578, 1586, 1628, 1632, 1675, 1686, 1690, 1698,
1723, 1733, 1737, 1745, 1775, 1802, 1817, 1835, 1854, 1860, 1864, 1868,
1879, 1892, 1894, 1896, 1915, 1918, 1930, 1947, 1951, 1968, 1978, 1984,
2037, 2042, 2045, 2070, 2075, 2086, 2106, 2125, 2186, 2199, 2205, 2290,
2302, 2303, 2332, 2338, 2347, 2363, 2368, 2381, 2382, 2417, 2440, 2441,
2449, 2464, 2466, 2471, 2500, 2512, 2519, 2548, 2549, 2557, 2568, 2578,
2580, 2582, 2617, 2618, 2694])
`
Then, when I compute the embeddings I get embeddings
variable of shape torch.Size([101, 64])
which refers to the embeddings on the variable unique_uic
respectively.
However, in order to feed them into another model, I need them to be in the following shape:
`In [34]:self.embeddings(torch.stack((u, i, c), dim=1))
Out[34]:
tensor([[ 820, 2568, 2694],
[ 820, 1802, 2694],
[ 820, 2578, 2694],
[ 820, 2580, 2694],
[ 820, 1044, 2694],
[ 820, 2070, 2694],
[ 820, 2582, 2694],
[ 820, 1817, 2694],
[ 820, 2075, 2694],
.........
[820, 2042, 2694],
[ 820, 2045, 2694],
[ 820, 2302, 2694],
[ 820, 2303, 2694]])
`
So, I should have the embeddings in shape [99, 3, 64] as it refers to the 99 interactions (in this example) of u-i-c. However, when I perform the embeddings I get embeddings from 0 to 101 corresponding to the unique id’s and I do not know how to perform the mapping in an efficient way.
If you could give me ideas it would be very helpful.
Thank you very much in advance!