Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save and restore partitioned variable in Tensorflow

I have a large matrix.

I use bellow way create this variable as number of shards.

softmax_w = tf.get_variable("softmax_w", [hps.vocab_size, hps.projected_size],
                            partitioner=tf.fixed_size_partitioner(hps.num_shards, 0))

create log:

model/softmax_w/part_0:0 (99184, 512) /cpu:0
model/softmax_w/part_1:0 (99184, 512) /cpu:0
model/softmax_w/part_2:0 (99184, 512) /cpu:0
model/softmax_w/part_3:0 (99184, 512) /cpu:0
model/softmax_w/part_4:0 (99184, 512) /cpu:0
model/softmax_w/part_5:0 (99184, 512) /cpu:0
model/softmax_w/part_6:0 (99183, 512) /cpu:0
model/softmax_w/part_7:0 (99183, 512) /cpu:0

I can training and save it success. But when I try to restore model I got this error:

W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_7 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_6 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_5 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_4 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_3 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_2 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_1 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_0 not found in checkpoint
W tensorflow/core/framework/op_kernel.cc:975] Not found: Key model/softmax_w/part_7 not found in checkpoint

I found tensorflow save the variable as a part. The saved parameter just have one softmax_w. No longer a partitioned variable.

like image 637
yi wang Avatar asked Dec 21 '16 09:12

yi wang


1 Answers

It happened in tensorflow 0.12 and doesn't happen in 1.3 (the last version as of October 2017). Here a GitHub issue, filed by the same author and now fixed. So if you see this error, just upgrade tensorflow.

like image 112
Maxim Avatar answered Oct 12 '22 01:10

Maxim