Python Tensorflow:导出模型处理时间

Python Tensorflow:导出模型处理时间,python,tensorflow,time,Python,Tensorflow,Time,是否有方法导出Tensorflow模型处理的时间 我想将它包含在一个脚本中,该脚本有一个for循环,用于测试不同的模型设置,以优化特定模型的准确性。了解/限制它的处理时间将非常有用(这样我可以让它在夜间运行,并在进一步的测试中排除需要太多处理时间的值)。 我已经可以用TensorBoard手动完成了,但当我想测试50多种不同的模型时,这就有点困难了。。。如果能将其包含在脚本中并使其自动运行,那就太好了。 谢谢你的帮助 #The model uses tf.keras.models.Sequent

是否有方法导出Tensorflow模型处理的时间

我想将它包含在一个脚本中,该脚本有一个
for
循环,用于测试不同的模型设置,以优化特定模型的准确性。了解/限制它的处理时间将非常有用(这样我可以让它在夜间运行,并在进一步的测试中排除需要太多处理时间的值)。
我已经可以用
TensorBoard
手动完成了,但当我想测试50多种不同的模型时,这就有点困难了。。。如果能将其包含在
脚本中并使其自动运行,那就太好了。
谢谢你的帮助

#The model uses tf.keras.models.Sequential

#Examples of variables
dense_layers =  [3, 4, 5]
layer_size =    [32, 64, 128]

for d in dense_layers:
    for s in layer_size:
        #Run model and get results to append on a list

PS:抱歉,如果这是在其他地方解释的,或者是重复的,但是Tensorflow的网页对初学者非常友好,当我在这里搜索主题时,我只发现有人抱怨他们的脚本迭代速度慢。

如果你真的只想从结果中排除那些训练时间太长的配置,你可以很容易地进行使用python中的
time
模块为培训过程计时。然后,仅当配置占用的时间少于给定的阈值时间时,才保存配置

import time
#The model uses tf.keras.models.Sequential

#Examples of variables
dense_layers =  [3, 4, 5]
layer_size =    [32, 64, 128]

time_threshold = 60*60*0.5 # upper time limit in seconds (example 30 mins)
successful_configurations = []

for d in dense_layers:
    for s in layer_size:
        tic = time.time()
        #Run model and get results to append on a list
        toc = time.time()
        execution_time = toc-tic

        if execution_time<time_threshold:
            config = {'accuracy': test_accuracy, 
                      'run_time': execution_time, 
                      'dense_layers': d,
                      'layer_size': s}

            successful_configurations.append(cofig)

导入时间
#该模型使用tf.keras.models.Sequential
#变量示例
密集_层=[3,4,5]
层大小=[32,64,128]
时间_阈值=60*60*0.5#时间上限(以秒为单位)(例如30分钟)
成功的_配置=[]
对于致密_层中的d:
对于层大小中的s:
tic=time.time()
#运行模型并获取要附加到列表中的结果
toc=时间。时间()
执行时间=toc tic
如果执行时间