neural-networks-and-deep-learning mnist_pca.py
来源:互联网 发布:西亚斯网络管理 编辑:程序博客网 时间:2024/05/17 05:54
这个程序主要的功能是通过pca来提取28*28的图片的pca然后还原。
"""mnist_pca~~~~~~~~~Use PCA to reconstruct some of the MNIST test digits."""# My librariesimport mnist_loader# Third-party librariesimport matplotlibimport matplotlib.pyplot as pltimport numpy as npfrom sklearn.decomposition import RandomizedPCA# Trainingtraining_data, validation_data, test_data = mnist_loader.load_data_wrapper()#此处就是将n_conponents设置为向量长度为99pca = RandomizedPCA(n_components=99)nn_images = [x for (x, y) in training_data]#此处上一步提取的x是一个列向量,所以按照列来进行concatenatepca_images = np.concatenate(nn_images, axis=1).transpose()pca_r = pca.fit(pca_images)# Try PCA on first ten test imagestest_images = validation_data[0][0].reshape((1,784));test_outputs = pca_r.inverse_transform(pca_r.transform(test_images))# Plot the first ten test images and the corresponding outputsfig = plt.figure()ax = fig.add_subplot(111)#此处的-1就是这一个维度是根据其他的维度进行计算出来的images_in = [validation_data[j][0].reshape(-1, 28) for j in range(1)]images_out = [test_outputs[j].reshape(-1, 28) for j in range(1)]image_in = np.concatenate(images_in, axis=1)image_out = np.concatenate(images_out, axis=1)image = np.concatenate([image_in, image_out])ax.matshow(image, cmap = matplotlib.cm.binary)plt.xticks(np.array([]))plt.yticks(np.array([]))plt.show()
0 0
- neural-networks-and-deep-learning mnist_pca.py
- neural-networks-and-deep-learning expand_mnist.py
- neural-networks-and-deep-learning mnist_average_darkness.py
- neural-networks-and-deep-learning mnist_svm.py
- neural-networks-and-deep-learning network.py
- neural-networks-and-deep-learning network2.py
- neural-networks-and-deep-learning test.py
- neural-networks-and-deep-learning network3.py
- neural-networks-and-deep-learning misleading_gradient.py
- neural-networks-and-deep-learning misleading_gradient_contours.py
- neural-networks-and-deep-learning backprop_magnitude_nabla.py
- neural-networks-and-deep-learning false_minimum.py
- neural-networks-and-deep-learning valley.py
- neural-networks-and-deep-learning valley2.py
- neural-networks-and-deep-learning weight_initialization.py
- neural-networks-and-deep-learning multiple_eta.py
- neural-networks-and-deep-learning more_data.py
- Neural Networks and Deep Learning
- fsl系统烧写工具MFGTool2工具详解
- 性能之procrank命令
- Zxing实现二维码生成,扫描代码段
- 杂杂的基础知识【Sizeof与Strlen&strcpy和memcpy&字符串常量和字符常量】
- UIScrollView的子视图的起点不是左上角
- neural-networks-and-deep-learning mnist_pca.py
- 189. Rotate Array
- hive体系结构
- php中global的使用
- 竞赛排名
- 元素查找
- Nginx配置完整例子
- (ios)使用视频(MP4)当做背景(如keep登录页)
- 杭电ACM 1021