-
Notifications
You must be signed in to change notification settings - Fork 3
/
debug.py
35 lines (30 loc) · 857 Bytes
/
debug.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
# -*- coding: utf-8 -*-
# Debug script, useless...
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision import transforms
from torch.autograd import Variable
import torchvision
from config import *
import numpy as np
from scipy import spatial
# dataSetI = [3, 45, 7, 2]
# dataSetII = [2, 54, 13, 15]
# result = 1 - spatial.distance.cosine(dataSetI, dataSetII)
# print(result)
#
# from sklearn.metrics.pairwise import cosine_similarity
# from scipy import sparse
# import numpy as np
# import scipy
#
# A = np.array([[0, 1, 0, 0, 1]])
# B = np.array([[0, 2, 0, 0, 2], [0, 4, 0, 0, 2]])
# result = 1-scipy.spatial.distance.cdist(A, B, metric='cosine')
# print(result)
x = np.random.random((1, 3, 224, 224))
x = torch.from_numpy(x).float()
var = Variable(x)
backbone = torchvision.models.resnet50(pretrained=True)
backbone(var)