回答編集履歴

1

データ作成~表示までのサンプル追加

2017/03/15 01:19

投稿

8524ba23
8524ba23

スコア38352

test CHANGED
@@ -39,3 +39,119 @@
39
39
  :(以下略)
40
40
 
41
41
  ```
42
+
43
+
44
+
45
+ 2017/03/15追記 : データ作成~表示までの実行例
46
+
47
+ --
48
+
49
+
50
+
51
+ - 可視化したいデータ作成
52
+
53
+ 参考:[TensorBoardで処理を可視化する](http://www.mwsoft.jp/programming/tensor/tutorial_tensorboad.html)
54
+
55
+ ```Python
56
+
57
+ # -*- coding: utf-8 -*-
58
+
59
+ import tensorflow as tf
60
+
61
+
62
+
63
+ # 足し算
64
+
65
+ with tf.name_scope('add_scope'):
66
+
67
+ x = tf.constant(1, name='x')
68
+
69
+ y = tf.constant(2, name='y')
70
+
71
+ z = x + y
72
+
73
+
74
+
75
+ # 上の結果に掛け算
76
+
77
+ with tf.name_scope('multiply_scope'):
78
+
79
+ zz = y * z
80
+
81
+
82
+
83
+ with tf.Session() as sess:
84
+
85
+ with tf.name_scope('init_scope'):
86
+
87
+ # WARNING:tensorflow:From hoge.py initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
88
+
89
+ # Instructions for updating:
90
+
91
+ # Use `tf.global_variables_initializer` instead.
92
+
93
+ #sess.run(tf.initialize_all_variables())
94
+
95
+ sess.run(tf.global_variables_initializer())
96
+
97
+ sess.run(zz)
98
+
99
+
100
+
101
+ # グラフを書こう
102
+
103
+ # AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter' #8164
104
+
105
+ # https://github.com/tensorflow/tensorflow/issues/8164
106
+
107
+ #summary_writer = tf.train.SummaryWriter('data', graph=sess.graph)
108
+
109
+ summary_writer = tf.summary.FileWriter('c:\\temp\\tf_log', graph=sess.graph)
110
+
111
+
112
+
113
+ # http://stackoverflow.com/questions/41066244/tensorflow-module-object-has-no-attribute-scalar-summary
114
+
115
+ #tf.scalar_summary('one_plus_one_summary', zz)
116
+
117
+ tf.summary.scalar('one_plus_one_summary', zz)
118
+
119
+
120
+
121
+ print("done.")
122
+
123
+ ```
124
+
125
+ `c:\temp\tf_log`配下にデータ`events.out.tfevents.1489539251.hoge-PC`が作成される。
126
+
127
+
128
+
129
+ - tensorboard起動
130
+
131
+ コマンドプロンプト(cmd.exe)上で以下を実行。
132
+
133
+ ```lang=DOS
134
+
135
+ C:\Windows\system32>activate tf3
136
+
137
+ (tf3) C:\Windows\system32>tensorboard --logdir=c:/temp/tf_log
138
+
139
+ Starting TensorBoard b'41' on port 6006
140
+
141
+ (You can navigate to http://172.xx.xx.xx:6006)
142
+
143
+ ERROR:tensorflow:Unable to get size of ~
144
+
145
+ など複数行のエラー、警告が表示されるがとりあえず無視
146
+
147
+ WARNING:tensorflow:Found more than one metagraph event per run. Overwriting the
148
+
149
+ metagraph with the newest event.
150
+
151
+ ```
152
+
153
+
154
+
155
+ - ブラウザ(chrome)で`http://localhost:6006`を開く
156
+
157
+ ![tensorboard](b882648cd39108a0e7f7860889507341.png)