forked from lawlite19/Blog-Back-Up
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
159 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
model_checkpoint_path: "model.ckpt-0" | ||
all_model_checkpoint_paths: "model.ckpt-0" |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
7 | ||
2 | ||
1 | ||
0 | ||
4 | ||
1 | ||
4 | ||
9 | ||
5 | ||
9 | ||
0 | ||
6 | ||
9 | ||
0 | ||
1 | ||
5 | ||
9 | ||
7 | ||
3 | ||
4 | ||
9 | ||
6 | ||
6 | ||
5 | ||
4 | ||
0 | ||
7 | ||
4 | ||
0 | ||
1 | ||
3 | ||
1 | ||
3 | ||
4 | ||
7 | ||
2 | ||
7 | ||
1 | ||
2 | ||
1 | ||
1 | ||
7 | ||
4 | ||
2 | ||
3 | ||
5 | ||
1 | ||
2 | ||
4 | ||
4 | ||
6 | ||
3 | ||
5 | ||
5 | ||
6 | ||
0 | ||
4 | ||
1 | ||
9 | ||
5 | ||
7 | ||
8 | ||
9 | ||
3 | ||
7 | ||
4 | ||
6 | ||
4 | ||
3 | ||
0 | ||
7 | ||
0 | ||
2 | ||
9 | ||
1 | ||
7 | ||
3 | ||
2 | ||
9 | ||
7 | ||
7 | ||
6 | ||
2 | ||
7 | ||
8 | ||
4 | ||
7 | ||
3 | ||
6 | ||
1 | ||
3 | ||
6 | ||
9 | ||
3 | ||
1 | ||
4 | ||
1 | ||
7 | ||
6 | ||
9 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
embeddings { | ||
tensor_name: "embedding:0" | ||
metadata_path: "metadata.tsv" | ||
sprite { | ||
image_path: "mnist_10k_sprite.png" | ||
single_image_dim: 28 | ||
single_image_dim: 28 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#-*- coding: utf-8 -*- | ||
# Author: Lawlite | ||
# Date: 2017/07/26 | ||
# Associate Blog: http://lawlite.me/2017/06/24/Tensorflow学习-工具相关/#1、可视化embedding | ||
# License: MIT | ||
|
||
import numpy as np | ||
import tensorflow as tf | ||
from tensorflow.contrib.tensorboard.plugins import projector | ||
from tensorflow.examples.tutorials.mnist import input_data | ||
import os | ||
|
||
MNIST_DATA_PATH = 'MNIST_data' | ||
LOG_DIR = 'log' | ||
SPRITE_IMAGE_FILE = 'mnist_10k_sprite.png' | ||
META_DATA_FILE = 'metadata.tsv' | ||
IMAGE_NUM = 100 | ||
|
||
mnist = input_data.read_data_sets(MNIST_DATA_PATH, one_hot=False) | ||
plot_array = mnist.test.images[:IMAGE_NUM] # 取前100个图片 | ||
np.savetxt(os.path.join(LOG_DIR, META_DATA_FILE), mnist.test.labels[:IMAGE_NUM], fmt='%d') # label 保存为metadata.tsv文件 | ||
|
||
|
||
'''可视化embedding, 3个步骤''' | ||
with tf.Session() as sess: | ||
'''1、 将2D矩阵放入Variable中国''' | ||
embeddings_var = tf.Variable(plot_array, name='embedding') | ||
tf.global_variables_initializer().run() | ||
|
||
'''2、 保存到文件中''' | ||
saver = tf.train.Saver([embeddings_var]) | ||
sess.run(embeddings_var.initializer) | ||
saver.save(sess, os.path.join(LOG_DIR, "model.ckpt"), global_step=0) | ||
|
||
'''3、 关联metadata和sprite图片''' | ||
summary_writer = tf.summary.FileWriter(LOG_DIR) | ||
config = projector.ProjectorConfig() | ||
embedding = config.embeddings.add() | ||
embedding.tensor_name = embeddings_var.name | ||
embedding.metadata_path = META_DATA_FILE | ||
embedding.sprite.image_path = SPRITE_IMAGE_FILE | ||
embedding.sprite.single_image_dim.extend([28, 28]) | ||
projector.visualize_embeddings(summary_writer, config) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters