-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestDimRed.py
34 lines (27 loc) · 1.15 KB
/
testDimRed.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
import numpy as np
from fastTSNE import TSNE
from sklearn import datasets
from gym_CTMaze.envs.CTMaze_plot import CTMaze_plot
from gym_CTMaze.envs import CTMaze_env
from gym_CTMaze.envs.CTMaze_conf import CTMaze_conf
from gym_CTMaze.envs.CTMaze_images import CTMaze_images
from learning.createDataset import CustomDatasetFromImages
configuration = CTMaze_conf("maze.json")
conf_data = configuration.getParameters()
imageDataset = CTMaze_images(conf_data)
print(imageDataset.image.shape)
imageDataset.image.shape
#plotting
CTMaze_plot.plotImages(imageDataset, False)
imgDataset = CustomDatasetFromImages(imageDataset)
#vectorisedImages = imageDataset.image.reshape(64,144)
#vectorisedImages.shape
imgDataset.imgdata.shape
vecImg = imgDataset.imgdata.reshape(320,144)
import torch
torch.randperm(144)
tsne = TSNE(n_components=2, perplexity=21, learning_rate=100, early_exaggeration=12, n_jobs=4, initialization='random', metric='euclidean', n_iter=750, early_exaggeration_iter=250, neighbors='exact', negative_gradient_method='bh', min_num_intervals=10, )
embedding = tsne.fit(vecImg)
embedding.shape
import matplotlib.pyplot as plt
plt.scatter(embedding[:,0],embedding[:,1])