簡體   English   中英

如何在Tensorflow中保存和還原分區變量

[英]How to save and restore partitioned variable in Tensorflow

我有一個大矩陣。

我使用波紋管方式將此變量創建為分片數。

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

創建日志:

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

我可以訓練並保存成功。 但是,當我嘗試還原模型時,出現此錯誤:

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

我發現張量流將變量另存為一部分。 保存的參數只有一個softmax_w 不再是分區變量。

它發生在tensorflow 0.12中,而沒有發生在1.3中(截至2017年10月的最新版本)。 這是GitHub問題 ,由同一作者提交,現已修復。 因此,如果看到此錯誤,則只需升級tensorflow。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM