In [24]:
%matplotlib inline
from double_qnet import *
import tensorflow as tf
import pickle
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
from matplotlib._png import read_png
In [2]:
import matplotlib.cm as cm
In [3]:
sess = tf.Session()
sess.run(tf.initialize_all_variables())
In [4]:
f = open('../data/color/transitions.pickle', 'r')
to_restore = pickle.load(f)
f.close()
In [5]:
frame_count, transitions = to_restore['frame_count'], to_restore['transitions']
In [6]:
print frame_count
sa, ta, aa, ra, spa = transitions.get_minibatch(frame_count)
foo = sess.run(r_h_fc1, feed_dict={s: sa})
In [8]:
model = TSNE()
transformed = model.fit_transform(foo)
In [94]:
for i in range(len(sa)):
if transformed[i,0]<-10 and transformed[i,1]>0:
print i
In [100]:
fig, ax = plt.subplots(figsize=(20,10))
max_height = 10*fig.dpi
max_width=20*fig.dpi
print (max_height, max_width)
x_pixels=max_width / float(35)
y_pixels = max_height / float(30)
indexes = [9832, 6794,32, 120]
for i in indexes:
imagebox=OffsetImage(255 - sa[i][:,:,:], zoom=0.6)
# arr_lena = read_png('../architecture.png')
# imagebox = OffsetImage(arr_lena, zoom=0.2)
xy=(transformed[i,0],transformed[i,1])
if xy[0] <= 0:
offset_x = 0-(xy[0]+20) * x_pixels + 250
else:
offset_x = max_width-(xy[0]+20)*x_pixels-250
print offset_x
if xy[1] <= 0:
offset_y = 0-(xy[1]+15)*y_pixels+150
else:
offset_y = max_height-(xy[1]+15)*y_pixels-150
offset = (offset_x,offset_y)
ab = AnnotationBbox(imagebox, xy,
xybox=offset,
xycoords='data',
boxcoords='offset points',
pad=0.5,
arrowprops=dict(arrowstyle="->"),
)
ax.add_artist(ab)
# plt.figure(figsize=(20, 10))
ax.scatter(transformed[:, 0], transformed[:, 1], c=aa, cmap="plasma", lw=0)
plt.draw()
plt.show()
In [101]:
fig, ax = plt.subplots(figsize=(20,10))
max_height = 10*fig.dpi
max_width=20*fig.dpi
print (max_height, max_width)
x_pixels=max_width / float(35)
y_pixels = max_height / float(30)
for i in indexes:
imagebox=OffsetImage(255 - sa[i][:,:,:], zoom=0.6)
# arr_lena = read_png('../architecture.png')
# imagebox = OffsetImage(arr_lena, zoom=0.2)
xy=(transformed[i,0],transformed[i,1])
if xy[0] <= 0:
offset_x = 0-(xy[0]+20) * x_pixels + 250
else:
offset_x = max_width-(xy[0]+20)*x_pixels-250
print offset_x
if xy[1] <= 0:
offset_y = 0-(xy[1]+15)*y_pixels+150
else:
offset_y = max_height-(xy[1]+15)*y_pixels-150
offset = (offset_x,offset_y)
ab = AnnotationBbox(imagebox, xy,
xybox=offset,
xycoords='data',
boxcoords='offset points',
pad=0.5,
arrowprops=dict(arrowstyle="->"),
)
ax.add_artist(ab)
# plt.figure(figsize=(20, 10))
ax.scatter(transformed[:, 0], transformed[:, 1], c=ra, cmap="plasma", lw=0)
plt.draw()
plt.show()
In [50]:
indexes = [1, 500, 999, 750]
for i in indexes:
plt.figure(figsize=(10, 10))
print sa[i].shape
plt.imshow(255 - sa[i][:,:,:])
plt.axis('off')
plt.title('initial image %d'%i)
plt.show()
# plt.imshow(spa[img_idx][:,:,0], cmap = cm.Greys_r)
# plt.axis('off')
# plt.title('next image %d'%i)
# plt.show()
In [ ]:
plt.imshow(spa[img_idx][:,:,0], cmap = cm.Greys_r)
In [ ]: