如何计算CNN模型训练过程的总运行时间

时间:2019-11-25 05:04:02

标签: tensorflow time model conv-neural-network

我需要获得CNN训练过程的总运行时间,但我不知道该如何获得。是否有任何软件包可以获取总运行时间?

我在这里有CNN训练过程的结果示例。如您所见,每个时期都有一个运行时间过程,但是我需要获得所有训练过程的总数。 谁能帮我吗?

Epoch 1/50
250/250 [==============================] - 18s 71ms/step - loss: 4.0427 - accuracy: 0.0111 - val_loss: 3.8992 - val_accuracy: 0.0200
Epoch 2/50
250/250 [==============================] - 17s 70ms/step - loss: 3.9247 - accuracy: 0.0160 - val_loss: 3.6276 - val_accuracy: 0.0800
Epoch 3/50
250/250 [==============================] - 18s 70ms/step - loss: 3.3692 - accuracy: 0.0546 - val_loss: 2.9868 - val_accuracy: 0.1200
Epoch 4/50
250/250 [==============================] - 17s 70ms/step - loss: 2.8787 - accuracy: 0.1194 - val_loss: 2.5775 - val_accuracy: 0.2000
Epoch 5/50
250/250 [==============================] - 18s 71ms/step - loss: 2.4328 - accuracy: 0.2992 - val_loss: 2.0736 - val_accuracy: 0.3600
Epoch 6/50
250/250 [==============================] - 18s 70ms/step - loss: 1.8779 - accuracy: 0.4849 - val_loss: 1.6079 - val_accuracy: 0.4800
Epoch 7/50
250/250 [==============================] - 18s 71ms/step - loss: 1.4844 - accuracy: 0.6018 - val_loss: 1.3112 - val_accuracy: 0.6800
Epoch 8/50
250/250 [==============================] - 17s 69ms/step - loss: 1.2182 - accuracy: 0.6820 - val_loss: 1.1277 - val_accuracy: 0.6200
Epoch 9/50
250/250 [==============================] - 18s 70ms/step - loss: 1.0166 - accuracy: 0.7420 - val_loss: 0.9915 - val_accuracy: 0.7000
Epoch 10/50
250/250 [==============================] - 17s 70ms/step - loss: 0.8404 - accuracy: 0.8148 - val_loss: 0.8455 - val_accuracy: 0.7600
Epoch 11/50
250/250 [==============================] - 18s 71ms/step - loss: 0.6988 - accuracy: 0.8659 - val_loss: 0.7465 - val_accuracy: 0.7800
Epoch 12/50
250/250 [==============================] - 18s 71ms/step - loss: 0.5902 - accuracy: 0.8940 - val_loss: 0.6760 - val_accuracy: 0.7600
Epoch 13/50
250/250 [==============================] - 18s 71ms/step - loss: 0.5075 - accuracy: 0.9091 - val_loss: 0.5958 - val_accuracy: 0.8400
Epoch 14/50
250/250 [==============================] - 18s 71ms/step - loss: 0.4247 - accuracy: 0.9260 - val_loss: 0.5684 - val_accuracy: 0.8000
Epoch 15/50
250/250 [==============================] - 18s 71ms/step - loss: 0.3621 - accuracy: 0.9402 - val_loss: 0.5031 - val_accuracy: 0.8000
Epoch 16/50
250/250 [==============================] - 17s 70ms/step - loss: 0.3124 - accuracy: 0.9460 - val_loss: 0.4263 - val_accuracy: 0.9000
Epoch 17/50
250/250 [==============================] - 17s 69ms/step - loss: 0.2622 - accuracy: 0.9550 - val_loss: 0.3983 - val_accuracy: 0.8800
Epoch 18/50
250/250 [==============================] - 18s 72ms/step - loss: 0.2351 - accuracy: 0.9547 - val_loss: 0.4028 - val_accuracy: 0.8200
Epoch 19/50
250/250 [==============================] - 18s 72ms/step - loss: 0.2002 - accuracy: 0.9666 - val_loss: 0.3812 - val_accuracy: 0.8600
Epoch 20/50
250/250 [==============================] - 18s 71ms/step - loss: 0.1770 - accuracy: 0.9693 - val_loss: 0.3330 - val_accuracy: 0.9000
Epoch 21/50
250/250 [==============================] - 18s 71ms/step - loss: 0.1538 - accuracy: 0.9762 - val_loss: 0.4010 - val_accuracy: 0.8600
Epoch 22/50
250/250 [==============================] - 18s 71ms/step - loss: 0.1446 - accuracy: 0.9736 - val_loss: 0.3387 - val_accuracy: 0.8600
Epoch 23/50
250/250 [==============================] - 18s 70ms/step - loss: 0.1171 - accuracy: 0.9850 - val_loss: 0.2887 - val_accuracy: 0.9400
Epoch 24/50
250/250 [==============================] - 18s 72ms/step - loss: 0.1301 - accuracy: 0.9712 - val_loss: 0.2748 - val_accuracy: 0.9400
Epoch 25/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0966 - accuracy: 0.9846 - val_loss: 0.2883 - val_accuracy: 0.9200
Epoch 26/50
250/250 [==============================] - 18s 72ms/step - loss: 0.0936 - accuracy: 0.9853 - val_loss: 0.2930 - val_accuracy: 0.8800
Epoch 27/50
250/250 [==============================] - 18s 70ms/step - loss: 0.1104 - accuracy: 0.9761 - val_loss: 0.2626 - val_accuracy: 0.9000
Epoch 28/50
250/250 [==============================] - 18s 71ms/step - loss: 0.1067 - accuracy: 0.9762 - val_loss: 0.3085 - val_accuracy: 0.8800
Epoch 29/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0903 - accuracy: 0.9808 - val_loss: 0.3507 - val_accuracy: 0.8600
Epoch 30/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0792 - accuracy: 0.9886 - val_loss: 0.2796 - val_accuracy: 0.9000
Epoch 31/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0554 - accuracy: 0.9940 - val_loss: 0.2505 - val_accuracy: 0.9000
Epoch 32/50
250/250 [==============================] - 18s 72ms/step - loss: 0.0734 - accuracy: 0.9861 - val_loss: 0.2937 - val_accuracy: 0.9000
Epoch 33/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0446 - accuracy: 0.9949 - val_loss: 0.2639 - val_accuracy: 0.9000
Epoch 34/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0685 - accuracy: 0.9866 - val_loss: 0.3331 - val_accuracy: 0.9000
Epoch 35/50
250/250 [==============================] - 18s 71ms/step - loss: 0.1402 - accuracy: 0.9643 - val_loss: 0.2561 - val_accuracy: 0.9400
Epoch 36/50
250/250 [==============================] - 18s 72ms/step - loss: 0.0424 - accuracy: 0.9962 - val_loss: 0.3020 - val_accuracy: 0.8600
Epoch 37/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0356 - accuracy: 0.9969 - val_loss: 0.2670 - val_accuracy: 0.9200
Epoch 38/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0380 - accuracy: 0.9958 - val_loss: 0.3640 - val_accuracy: 0.8400
Epoch 39/50
250/250 [==============================] - 18s 70ms/step - loss: 0.0960 - accuracy: 0.9793 - val_loss: 0.3186 - val_accuracy: 0.8800
Epoch 40/50
250/250 [==============================] - 18s 72ms/step - loss: 0.0394 - accuracy: 0.9945 - val_loss: 0.2686 - val_accuracy: 0.9000
Epoch 41/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0364 - accuracy: 0.9955 - val_loss: 0.3073 - val_accuracy: 0.9000
Epoch 42/50
250/250 [==============================] - 18s 70ms/step - loss: 0.1673 - accuracy: 0.9567 - val_loss: 0.3678 - val_accuracy: 0.9000
Epoch 43/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0366 - accuracy: 0.9992 - val_loss: 0.3368 - val_accuracy: 0.8800
Epoch 44/50
250/250 [==============================] - 18s 72ms/step - loss: 0.0318 - accuracy: 0.9992 - val_loss: 0.3261 - val_accuracy: 0.8800
Epoch 45/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0338 - accuracy: 0.9969 - val_loss: 0.3418 - val_accuracy: 0.9000
Epoch 46/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0265 - accuracy: 0.9987 - val_loss: 0.3504 - val_accuracy: 0.8600
Epoch 47/50
250/250 [==============================] - 18s 71ms/step - loss: 0.0286 - accuracy: 0.9969 - val_loss: 0.3072 - val_accuracy: 0.9200
Epoch 48/50
250/250 [==============================] - 18s 72ms/step - loss: 0.1499 - accuracy: 0.9646 - val_loss: 0.2840 - val_accuracy: 0.9200
Epoch 49/50
250/250 [==============================] - 17s 70ms/step - loss: 0.0348 - accuracy: 0.9992 - val_loss: 0.2803 - val_accuracy: 0.9000
Epoch 50/50
250/250 [==============================] - 17s 70ms/step - loss: 0.0275 - accuracy: 0.9986 - val_loss: 0.3138 - val_accuracy: 0.9200

1 个答案:

答案 0 :(得分:0)

您可以尝试一下

import time

start = time.time()
model.fit() # Training statement
print("Total time: ", time.time() - start, "seconds")