如何在for循环中使用tf.estimator.predict?

时间:2019-06-11 18:21:50

标签: tensorflow

我想在tensorflow中使用tf.predict函数提供一些帮助。对于一个项目,我需要对该函数进行连续循环,但是现在它相当慢,因为它需要在每个循环中加载检查点。 这个示例有点简化,在实际代码中,我使用了60个这些模型,并且需要同时进行预测。当我给它们计时时,其中的60个大约需要76秒。我的目标是使它们在10秒以下。我相信,大多数时间都浪费了,因为需要在每个实例中重新加载模型。 有没有办法在运行循环之前加载模型?

这是每个循环发生的事情:

INFO:tensorflow:调用model_fn。

INFO:tensorflow:完成调用model_fn。

INFO:tensorflow:图已完成。

INFO:tensorflow:从Model_folder_AC1 / model.ckpt-35000恢复参数

INFO:tensorflow:正在运行local_init_op。

INFO:tensorflow:已运行local_init_op。

In [21]: import re                                                                                    

In [22]: aa="may_be_this_also.is_the_string"                                                          

In [23]: re.split('this(_also)+.', aa)                                                                
Out[23]: ['may_be_', 'is_the_string']

In [24]: aa="may_be_this.is_the_string"                                                               

In [25]: re.split('this.', aa)                                                                        
Out[25]: ['may_be_', 'is_the_string']

0 个答案:

没有答案