如何在Tensorflow中恢复定义为dict的图形

时间:2017-08-03 08:43:55

标签: python tensorflow

我意识到有关于恢复/搜查检查点的帖子。但是,我想确保我的图表作为dict正确加载,并且我的feed_dic再次正常。

我目前正在做:

sess=tf.Session()
saver = tf.train.import_meta_graph('./saves/model.meta') 
graph = tf.get_default_graph()

with tf.Session() as sess:

    # LOAD THE TRAINED MODEL
    saver.restore(sess, tf.train.latest_checkpoint('./saves/model'))

我的图g最初是这样构建的(这是我想要的变量:

return dict(
    x=x,
    y=y,
    init_state=init_state,
    final_state=final_state,
    total_loss=total_loss,
    train_step=train_step,
    tonnetz_loss=tonnetz_loss,
    valid_loss = valid_loss,
    preds=predictions,
    training_op_cnn=training_op_cnn,
    loss_cnn=loss_cnn,
    autoencoder_outputs=autoencoder_outputs,
    final_w = final_w,
    weight2 = weight2,
    weight1 = weight1,
    bias1 = bias1,
    bias2 = bias2,
    final_b = final_b,
    fixed_w1 = fixed_w1,
    fixed_b1 = fixed_b1,
    fixed_w2 = fixed_w2,
    fixed_b2 = fixed_b2,
    fixed_final_w = fixed_final_w,
    fixed_final_b = fixed_final_b,
    saver=tf.train.Saver()
)

我不知道如何再次恢复完整的dict,并将feed_dict正确设置为最后一个状态+加载所有正确的信息。

0 个答案:

没有答案