質問編集履歴
4
試したこと2の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
-
### 試したこと
|
51
|
+
### 試したこと1
|
52
52
|
|
53
53
|
|
54
54
|
|
@@ -172,6 +172,38 @@
|
|
172
172
|
|
173
173
|
|
174
174
|
|
175
|
+
### 試したこと2
|
176
|
+
|
177
|
+
[参考記事の実行コマンド](https://qiita.com/48saaan/items/1661a912c740308d3fd5)では、Mフォルダがないというエラーが出ていたので、Mフォルダのないコマンドで試したところ。さらに別のエラーが出て、解決できませんでした。
|
178
|
+
|
179
|
+
```bash
|
180
|
+
|
181
|
+
$ test/models/research/im2txt/bazel-bin/im2txt/run_inference --checkpoint_path="test/models/research/im2txt/model.ckpt-2000000" --vocab_file="test/models/research/im2txt/word_counts.txt" --input_files="test/models/research/im2txt/im2txt/cat.jpg"
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
```
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
エラー文
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
Key lstm/basic_lstm_cell/bias not found in checkpoint
|
198
|
+
|
199
|
+
[[node save/RestoreV2 (defined at /Users/username/Desktop/show_and_tell/test/models/research/im2txt/bazel-bin/im2txt/run_inference.runfiles/im2txt/im2txt/inference_utils/inference_wrapper_base.py:116) = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
|
206
|
+
|
175
207
|
### 補足情報(FW/ツールのバージョンなど)
|
176
208
|
|
177
209
|
MacOS mojave
|
3
試したことの追記修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -146,7 +146,29 @@
|
|
146
146
|
|
147
147
|
```
|
148
148
|
|
149
|
+
しかし、階層を変えて
|
149
150
|
|
151
|
+
```
|
152
|
+
|
153
|
+
OLD_CHECKPOINT_FILE = "test/models/research/im2txt/model.ckpt-2000000"
|
154
|
+
|
155
|
+
NEW_CHECKPOINT_FILE = "test/models/research/im2txt/model.ckpt-2000000"
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
にしたところ、エラーは起きず、
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
model.ckpt-2000000.data-00000-of-00001
|
164
|
+
|
165
|
+
model.ckpt-2000000.index
|
166
|
+
|
167
|
+
model.ckpt-2000000.meta
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
の3つのファイルが生成されました。
|
150
172
|
|
151
173
|
|
152
174
|
|
2
試したことの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,6 +48,106 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
+
### 試したこと
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
参考記事の「トレーニング済みモデルの準備」で処理しなければならない`model.ckpt-2000000`というファイルの変更日が2016年になっていたので、再度[参考記事](https://qiita.com/48saaan/items/1661a912c740308d3fd5#%E3%83%88%E3%83%AC%E3%83%BC%E3%83%8B%E3%83%B3%E3%82%B0%E6%B8%88%E3%81%BF%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E6%BA%96%E5%82%99)に明記されていた以下のコードを実行して処理したところ、エラーが表示されました。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
参考記事とは異なるファイル階層で、プログラムを実行したので最初の2行は、参考記事から変更しました。
|
60
|
+
|
61
|
+
```python
|
62
|
+
|
63
|
+
OLD_CHECKPOINT_FILE = "model.ckpt-2000000"
|
64
|
+
|
65
|
+
NEW_CHECKPOINT_FILE = "model.ckpt-2000000"
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
import tensorflow as tf
|
70
|
+
|
71
|
+
vars_to_rename = {
|
72
|
+
|
73
|
+
"lstm/BasicLSTMCell/Linear/Matrix": "lstm/basic_lstm_cell/weights",
|
74
|
+
|
75
|
+
"lstm/BasicLSTMCell/Linear/Bias": "lstm/basic_lstm_cell/biases",
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
new_checkpoint_vars = {}
|
80
|
+
|
81
|
+
reader = tf.train.NewCheckpointReader(OLD_CHECKPOINT_FILE)
|
82
|
+
|
83
|
+
for old_name in reader.get_variable_to_shape_map():
|
84
|
+
|
85
|
+
if old_name in vars_to_rename:
|
86
|
+
|
87
|
+
new_name = vars_to_rename[old_name]
|
88
|
+
|
89
|
+
else:
|
90
|
+
|
91
|
+
new_name = old_name
|
92
|
+
|
93
|
+
new_checkpoint_vars[new_name] = tf.Variable(reader.get_tensor(old_name))
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
init = tf.global_variables_initializer()
|
98
|
+
|
99
|
+
saver = tf.train.Saver(new_checkpoint_vars)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
with tf.Session() as sess:
|
104
|
+
|
105
|
+
sess.run(init)
|
106
|
+
|
107
|
+
saver.save(sess, NEW_CHECKPOINT_FILE)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
エラー文
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
$ python checkpoint_change.py
|
120
|
+
|
121
|
+
2018-11-11 14:45:58.509219: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
|
122
|
+
|
123
|
+
2018-11-11 14:46:17.630002: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at save_restore_v2_ops.cc:109 : Not found: ; No such file or directory
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
(略)
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
During handling of the above exception, another exception occurred:
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
Traceback (most recent call last):
|
136
|
+
|
137
|
+
File "checkpoint_change.py", line 23, in <module>
|
138
|
+
|
139
|
+
saver.save(sess, NEW_CHECKPOINT_FILE)
|
140
|
+
|
141
|
+
File "/Users/username/anaconda/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1458, in save
|
142
|
+
|
143
|
+
raise exc
|
144
|
+
|
145
|
+
ValueError: Parent directory of model.ckpt-2000000 doesn't exist, can't save.
|
146
|
+
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
|
51
151
|
|
52
152
|
|
53
153
|
### 補足情報(FW/ツールのバージョンなど)
|
1
タグの追記
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|