-
Notifications
You must be signed in to change notification settings - Fork 58
/
test_scrip.py
42 lines (34 loc) · 909 Bytes
/
test_scrip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import torch
from geomloss import SamplesLoss
device = "cuda"
tdtype = torch.float
x = torch.randn((3, 8, 2), dtype=torch.float, device=device)
y = torch.randn((3, 15, 2), dtype=torch.float, device=device)
P = [1, 2]
Debias = [True, False]
potential = False
for p in P:
for debias in Debias:
L_tensorized = SamplesLoss(
"sinkhorn",
p=p,
blur=0.5,
potentials=potential,
debias=debias,
backend="tensorized",
)
# a, b= L_tensorized(x, y)
A = L_tensorized(x, y)
L_online = SamplesLoss(
"sinkhorn",
p=p,
blur=0.5,
potentials=potential,
debias=debias,
backend="online",
)
# c, d= L_online(x, y)
B = L_tensorized(x, y)
# print(a, b)
# print(c, d)
print(torch.norm(A - B))