Open dongheechoi opened 4 years ago
http://163.152.20.6:8888/lab/tree/dh.ipynb 암호 : 1234
해결 -> LongTensor였어야 함. m.hour_embedding(torch.LongTensor([0.,1.]).cuda())
Code
from sklearn.manifold import TSNE %matplotlib inline import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D arr = m.hour_embedding(torch.LongTensor([float(i) for i in range(24)]).cuda()).cpu().detach().numpy() tsne = TSNE(n_components=2, verbose=1, perplexity=40, n_iter=300) tsne_results = tsne.fit_transform(arr)
res array([[ 6.52357407e+01, 2.97109871e+01], [ 7.22931480e+00, -1.17531822e+02], [ 9.38050938e+00, 1.25519302e+02], [-5.00310135e+01, -2.23163605e+01], [-1.00831932e+02, -7.36254959e+01], [ 8.21195374e+01, -1.00142166e+02], [ 1.58067169e+02, -8.27860413e+01], [ 4.22641830e+01, -5.91689301e+01], [-4.04240417e+01, 8.13821793e+01], [-8.41493912e+01, 1.18714699e+02], [-5.41209459e+00, -4.35924416e+01], [-4.62892342e+01, 1.74711166e+02], [-1.54264862e+02, -1.80793495e+01], [ 2.49544926e+01, 1.54471397e-02], [ 7.10910492e+01, 9.26024246e+01], [ 1.06514442e+02, -2.95543060e+02], [-2.05398598e+01, 2.42003193e+01], [-7.22683792e+01, 3.53312378e+01], [-1.01585526e+02, -1.00038815e+01], [ 1.22630280e+02, 3.59977837e+01], [-1.23820366e+02, 6.02001953e+01], [ 9.57163010e+01, -2.74828587e+01], [ 1.43090353e+01, 6.53545151e+01], [-4.44189644e+01, -8.75185699e+01]], dtype=float32)
조금씩 다르게 나옴
숫자 붙여봄
def plot2(arr):
tsne = TSNE(n_components=2, verbose=1, perplexity=40, n_iter=300)
tsne_results = tsne.fit_transform(arr)
tr = tsne_results.transpose()
x1 = tr[0][:24]
y1 = tr[1][:24]
x2 = tr[0][24:]
y2 = tr[1][24:]
plt.figure(figsize=(16,10))
fig, ax = plt.subplots()
ax.scatter(x=x1, y=y1, marker='^')
ax.scatter(x=x2, y=y2, marker='o')
for i in range(len(x1)):
ax.annotate('d'+str(i), (x1[i], y1[i]))
ax.annotate('n'+str(i), (x2[i], y2[i]))
return tsne_results
hd_arr = np.vstack(
[[np.array([np.append(he, d_arr[0]) for he in h_arr])],
[np.array([np.append(he, d_arr[1]) for he in h_arr])]]
)
# 0~23 :
arr = hd_arr.reshape(-1, 64)
tnse_res = plot2(arr)
arr = m.location_embedding(torch.LongTensor([float(i) for i in range(171)]).cuda())
arr = arr.cpu().detach().numpy()
tnse_res = plot(arr)
조정하니 좀 나뉘긴함.
이거도 좀 신기하게 나뉘네
시각화 고생하셨습니다!
bss_prediction_1019_16.pdf
암호 : 1234
시각화
Station Embedding 시각화
time embedding 시각화
Demand 시각화
Todo-list
모델 저장하는 부분 구현