import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
import os
from tensorflow.examples.tutorials.mnist import input_data LOG_DIR = 'log'
SPRITE_FILE = 'mnist_sprite.jpg'
META_FIEL = "mnist_meta.tsv" def create_sprite_image(images):
"""Returns a sprite image consisting of images passed as argument. Images should be count x width x height"""
if isinstance(images, list):
images = np.array(images)
img_h = images.shape[1]
img_w = images.shape[2]
n_plots = int(np.ceil(np.sqrt(images.shape[0]))) # 大图长和宽的值 spriteimage = np.ones((img_h * n_plots, img_w * n_plots)) # 一块白板 for i in range(n_plots):
for j in range(n_plots):
this_filter = i * n_plots + j
if this_filter < images.shape[0]:
this_img = images[this_filter] # 往里填充
spriteimage[i * img_h:(i + 1) * img_h,
j * img_w:(j + 1) * img_w] = this_img return spriteimage mnist = input_data.read_data_sets("./MNIST_data", one_hot=False)
to_visualise = 1 - np.reshape(mnist.test.images, (-1, 28, 28)) # 数字由白变黑
sprite_image = create_sprite_image(to_visualise)
path_for_mnist_sprites = os.path.join(LOG_DIR, SPRITE_FILE)
plt.imsave(path_for_mnist_sprites, sprite_image, cmap='gray') # 这里写入的是jpg文件
plt.imshow(sprite_image, cmap='gray') path_for_mnist_metadata = os.path.join(LOG_DIR, META_FIEL) with open(path_for_mnist_metadata,'w') as f: # 这里写入的是tsv文件
f.write("Index\tLabel\n")
for index,label in enumerate(mnist.test.labels):
f.write("%d\t%d\n" % (index,label))

Tensorflow细节-P309-高维向量可视化的更多相关文章

  1. Tensorboard教程:高维向量可视化

    Tensorflow高维向量可视化 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考文献 强烈推荐Tensorflow实战Google深度学习框架 实验平台: Tensorflow1.4. ...

  2. Tensorflow细节-P309-监控指标可视化

    注意下面一个点就ok了 with tf.name_scope('input_reshape'): # 注意看这里,图片的生成 image_shaped_input = tf.reshape(x, [- ...

  3. 词向量可视化--[tensorflow , python]

    #!/usr/bin/env python # -*- coding: utf-8 -*- """ ---------------------------------- ...

  4. Tensorflow细节-Tensorboard可视化-简介

    先搞点基础的 注意注意注意,这里虽然很基础,但是代码应注意: 1.从writer开始后边就错开了 2.writer后可以直接接writer.close,也就是说可以: writer = tf.summ ...

  5. Tensorflow 搭建神经网络及tensorboard可视化

    1. session对话控制 matrix1 = tf.constant([[3,3]]) matrix2 = tf.constant([[2],[2]]) product = tf.matmul(m ...

  6. 超简单tensorflow入门优化程序&&tensorboard可视化

    程序1 任务描述: x = 3.0, y = 100.0, 运算公式 x×W+b = y,求 W和b的最优解. 使用tensorflow编程实现: #-*- coding: utf-8 -*-) im ...

  7. Tensorflow细节-P312-PROJECTOR

    首先进行数据预处理,需要生成.tsv..jpg文件 import matplotlib.pyplot as plt import numpy as np import os from tensorfl ...

  8. TensorFlow基础笔记(9) Tensorboard可视化显示以及查看pb meta模型文件的方法

    参考: http://blog.csdn.net/l18930738887/article/details/55000008 http://www.jianshu.com/p/19bb60b52dad ...

  9. Tensorflow细节-P319-使用GPU基本的操作

    如果什么都不加,直接运行装了GPU的Tensorflow,结果是这样子的 import tensorflow as tf a = tf.constant([1.0, 2.0, 3.0], shape= ...

随机推荐

  1. AX 2012 Computed column IIF语句使用

    涉及Dynamics ax 行业已经好几年了,准备总结一些有用的处理方法供大家来参考 首先先介绍下Computed column技术,该技术是微软在AX2012版本中提供的新技术,可以让SQL语句在A ...

  2. Rsync学习之旅中

    rsync配置文件详解 配置文件内容说明 man rsyncd.conf 全局参数 rsyncd.conf参数 参数说明 uid=rsync 运行rsync守护进程的用户. gid=rsync 运行r ...

  3. python 2种创建多线程的方法

    多个线程是可以操作同一个全局变量的,因此,可以通过这种方式来判断所有线程的执行进度 # 第一种方法:将要执行的方法作为参数传给Thread的构造方法 import threading import t ...

  4. VMware 网络介绍

       3.1 网卡介绍 如图所示,你的机器有两块网卡,一个是有线,一个是无线. 装完VM之后,会出现两块虚拟网卡,如图 VM有四种连接方式,我们着重介绍前三种    3.2 桥接 选择桥接模式,说明V ...

  5. DotNet Core 2.2 MVC Razor 页面编译为 View.dll 文件的解决方法

    使用文本文件编辑器打开项目文件,找到: <PropertyGroup>     <TargetFramework>netcoreapp2.0</TargetFramewo ...

  6. Angular—入门环境,项目创建,导入项目

    1.安装 nodejs,npm nodejs 下载地址: https://nodejs.org/en/download/

  7. AWS--Lamdba

    分享一个Lambda相关的连接 https://blog.csdn.net/m0_37204491/article/details/72829477

  8. 2019 朗玛信息java面试笔试题 (含面试题解析)

    本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.朗玛信息等公司offer,岗位是Java后端开发,最终选择去了朗玛信息. 面试了很多家公司,感觉大部分公司考察的点 ...

  9. python小作业

    目录 1.简述变量命名规范 2.name = input(">>>") name变量是什么数据类型通过代码检测 3.if条件语句的基本结构? 4.用print打印 ...

  10. iOS 12中获取WiFi的SSID

    开始搞智能家居,wifi获取不到了?? 小插曲 旧方法失效,19-12-15更新,ios13开始需要请求定位信息 SSID全称Service Set IDentifier, 即Wifi网络的公开名称. ...