update
This commit is contained in:
@ -89,9 +89,7 @@ plt.ion() # continuously plot
|
||||
# original data (first row) for viewing
|
||||
view_data = Variable(train_data.train_data[:N_TEST_IMG].view(-1, 28*28).type(torch.FloatTensor)/255.)
|
||||
for i in range(N_TEST_IMG):
|
||||
a[0][i].imshow(np.reshape(view_data.data.numpy()[i], (28, 28)), cmap='gray')
|
||||
a[0][i].set_xticks(())
|
||||
a[0][i].set_yticks(())
|
||||
a[0][i].imshow(np.reshape(view_data.data.numpy()[i], (28, 28)), cmap='gray'); a[0][i].set_xticks(()); a[0][i].set_yticks(())
|
||||
|
||||
for epoch in range(EPOCH):
|
||||
for step, (x, y) in enumerate(train_loader):
|
||||
@ -114,10 +112,8 @@ for epoch in range(EPOCH):
|
||||
for i in range(N_TEST_IMG):
|
||||
a[1][i].clear()
|
||||
a[1][i].imshow(np.reshape(decoded_data.data.numpy()[i], (28, 28)), cmap='gray')
|
||||
a[1][i].set_xticks(())
|
||||
a[1][i].set_yticks(())
|
||||
plt.draw()
|
||||
plt.pause(0.05)
|
||||
a[1][i].set_xticks(()); a[1][i].set_yticks(())
|
||||
plt.draw(); plt.pause(0.05)
|
||||
|
||||
plt.ioff()
|
||||
plt.show()
|
||||
@ -125,16 +121,10 @@ plt.show()
|
||||
# visualize in 3D plot
|
||||
view_data = Variable(train_data.train_data[:200].view(-1, 28*28).type(torch.FloatTensor)/255.)
|
||||
encoded_data, _ = autoencoder(view_data)
|
||||
fig = plt.figure(2)
|
||||
ax = Axes3D(fig)
|
||||
X = encoded_data.data[:, 0].numpy()
|
||||
Y = encoded_data.data[:, 1].numpy()
|
||||
Z = encoded_data.data[:, 2].numpy()
|
||||
fig = plt.figure(2); ax = Axes3D(fig)
|
||||
X, Y, Z = encoded_data.data[:, 0].numpy(), encoded_data.data[:, 1].numpy(), encoded_data.data[:, 2].numpy()
|
||||
values = train_data.train_labels[:200].numpy()
|
||||
for x, y, z, s in zip(X, Y, Z, values):
|
||||
c = cm.rainbow(int(255*s/9))
|
||||
ax.text(x, y, z, s, backgroundcolor=c)
|
||||
ax.set_xlim(X.min(), X.max())
|
||||
ax.set_ylim(Y.min(), Y.max())
|
||||
ax.set_zlim(Z.min(), Z.max())
|
||||
c = cm.rainbow(int(255*s/9)); ax.text(x, y, z, s, backgroundcolor=c)
|
||||
ax.set_xlim(X.min(), X.max()); ax.set_ylim(Y.min(), Y.max()); ax.set_zlim(Z.min(), Z.max())
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user