How to log Keras loss output to a file

前端 未结 6 1714
野的像风
野的像风 2020-12-04 15:39

When you run a Keras neural network model you might see something like this in the console:

Epoch 1/3
   6/1000 [..............................] - ETA: 7994         


        
6条回答
  •  借酒劲吻你
    2020-12-04 15:59

    You can redirect the sys.stdout object to a file before the model.fit method and reassign it to the standard console after model.fit method as follows:

    import sys
    oldStdout = sys.stdout
    file = open('logFile', 'w')
    sys.stdout = file
    model.fit(Xtrain, Ytrain)
    sys.stdout = oldStdout
    

提交回复
热议问题