def visualiseLearnedFeatures(self):
"""
Visualise the features learned by the autoencoder
"""
import matplotlib.pyplot as plt
extent = np.sqrt(self._architecture[0]) # size of input vector is stored in self._architecture
# number of rows and columns to plot (number of hidden units also stored in self._architecture)
plotDims = np.rint(np.sqrt(self._architecture[1]))
plt.ion()
fig = plt.figure()
plt.set_cmap("gnuplot")
plt.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9, wspace=-0.6, hspace=0.1)
learnedFeatures = self.getLearnedFeatures()
for i in range(self._architecture[1]):
image = np.reshape(learnedFeatures[i,:], (extent, extent), order="F") * 1000
ax = fig.add_subplot(plotDims, plotDims, i)
plt.axis("off")
ax.imshow(image, interpolation="nearest")
plt.show()
input("Program paused. Press enter to continue.")
评论列表
文章目录