質問編集履歴

1

質問変更

2017/09/03 08:08

投稿

trafalbad
trafalbad

スコア303

test CHANGED
@@ -1 +1 @@
1
- tf.train.get_checkpoint_stateにはcheckpointディレク内のファイルを指定ればいいのか
1
+ 複数のリスト内の行列を順番通りに一つリスト内に格納る方法
test CHANGED
@@ -1,103 +1,117 @@
1
- sessを保存し、checkpoint_dir(cifar-10-batches-py)に保存しした。
1
+ 次のような100個の数値を持つリストが5つあり
2
2
 
3
3
 
4
4
 
5
+ リストa1```array([[1],
6
+
7
+ [2],
8
+
9
+ [3],
10
+
11
+ ...,
12
+
13
+ [98],
14
+
15
+ [99],
16
+
17
+ [100]], dtype=uint8)```
18
+
19
+
20
+
21
+ リストa2```array([[101],
22
+
23
+ [102],
24
+
25
+ [103],
26
+
27
+ ...,
28
+
29
+ [198],
30
+
31
+ [199],
32
+
33
+ [200]], dtype=uint8)```
34
+
35
+ リストa3同様に```201~300```
36
+
37
+ リストa4同様に```301~400```
38
+
39
+ リストa5同様に```401~500```
40
+
41
+
42
+
5
- 500stepごとsessを保存したファイルが保存されてです、保存したsessを呼び出すときの```tf.train.get_checkpoint_state```のファイル名には何を指定すれば良いのでしょうか
43
+ このリストa1〜5までの数値を順番通りに、次のように一つのリスト(リストA)内に格納(1~500の行列)したい場合どようなやり方あるんでしょうか
44
+
45
+ リストA:```array([[1],
46
+
47
+ [2],
48
+
49
+ [3],
50
+
51
+ ...,
52
+
53
+ [498],
54
+
55
+ [499],
56
+
57
+ [500]], dtype=uint8)```
58
+
59
+
60
+
61
+ for文でできたりするのでしょうか?何かいい方法があったら教えていただけないしょうか?
6
62
 
7
63
 
8
64
 
9
65
 
10
66
 
11
- ファイル名一覧
12
-
13
- ・checkpoint
14
-
15
- ・model.ckpt-4693.data-00000-of-00001
67
+ また同じ作業を次のようにarrayでない行列に同様に実行する(リストBに順番通りに格納して一つにする)には同じ方法でも良いでしょうか?
16
-
17
- ・model.ckpt-4693.index
18
-
19
- ・model.ckpt-4693.meta
20
68
 
21
69
 
22
70
 
23
- sess呼び出しコード
71
+ リストb1```[1,
24
72
 
25
- ```
73
+ 2,
26
74
 
27
- with tf.Session() as sess:
75
+ 3,
28
76
 
29
- ckpt = tf.train.get_checkpoint_state('/Users/Downloads/cifar-10-batches-py/ここにファイルを指定する')
77
+ ...,
30
78
 
31
- if ckpt and ckpt.model_checkpoint_path:
79
+ 99,
32
80
 
33
- # Restores from checkpoint
34
-
35
- saver.restore(sess, ckpt.model_checkpoint_path)
36
-
37
- # Assuming model_checkpoint_path looks something like:
38
-
39
- # /my-favorite-path/cifar10_train/model.ckpt-0,
40
-
41
- # extract global_step from it.
42
-
43
- global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
44
-
45
- else:
46
-
47
- print('No checkpoint file found')
48
-
49
- return
81
+ 100]```
50
82
 
51
83
 
52
84
 
53
- # Start the queue runners.
85
+ リストb2```[101,
54
86
 
55
- coord = tf.train.Coordinator()
87
+ 102,
56
88
 
57
- try:
89
+ 103,
58
90
 
59
- threads = []
91
+ ...,
60
92
 
61
- for qr in tf.get_collection(tf.GraphKeys.QUEUE_RUNNERS):
93
+ 199,
62
94
 
95
+ 200]```
96
+
63
- threads.extend(qr.create_threads(sess, coord=coord, daemon=True, start=True))
97
+ リストb3同様に```201~300```
98
+
99
+ リストb4同様に```301~400```
100
+
101
+ リストb5同様に```401~500```
102
+
103
+ リストB内に格納(1~500)
64
104
 
65
105
 
66
106
 
67
- num_iter = int(math.ceil(10000 / 128))
107
+ リストB:```[1,
68
108
 
69
- true_count = 0 # Counts the number of correct predictions.
109
+ 2,
70
110
 
71
- total_sample_count = num_iter * FLAGS.batch_size
111
+ 3,
72
112
 
73
- step = 0
113
+ ...,
74
114
 
75
- while step < num_iter and not coord.should_stop():
115
+ 499,
76
116
 
77
- predictions = sess.run([top_k_op])
78
-
79
- true_count += np.sum(predictions)
80
-
81
- step += 1
82
-
83
-
84
-
85
- # Compute precision @ 1.
86
-
87
- precision = true_count / total_sample_count
88
-
89
- print('%s: precision @ 1 = %.3f' % (datetime.now(), precision))
90
-
91
-
92
-
93
- except Exception as e: # pylint: disable=broad-except
94
-
95
- coord.request_stop(e)
96
-
97
-
98
-
99
- coord.request_stop()
100
-
101
- coord.join(threads, stop_grace_period_secs=10)
102
-
103
- ```
117
+ 500]```