Python 我如何编写一个for循环,它可以每10个纪元给出一个输出

Python 我如何编写一个for循环,它可以每10个纪元给出一个输出,python,tensorflow,Python,Tensorflow,在训练之后,我的模型一次输出所有的历次,并给出一个最终的性能指标。我怎样才能得到它,使它每10个纪元打印一个带有性能指示器的纪元 model=baseline\u model() 模型拟合(X_序列,y_序列,历次=50) y_pred=模型预测(X) 使用回调 import keras class Callback(keras.callbacks.Callback): def __init__(self, acc_threshold): super(Callback,

在训练之后,我的模型一次输出所有的历次,并给出一个最终的性能指标。我怎样才能得到它,使它每10个纪元打印一个带有性能指示器的纪元

model=baseline\u model()
模型拟合(X_序列,y_序列,历次=50)
y_pred=模型预测(X)
使用回调

import keras

class Callback(keras.callbacks.Callback):
    def __init__(self, acc_threshold):
        super(Callback, self).__init__()

    def on_epoch_end(self, epoch, logs={}):
         if epoch % 10 == 0:
             performance_indicator()
例如:

model = baseline_model()
c = Callback(0.05)
model.fit(X_train, y_train, epochs=50, callbacks=[c])
y_pred = model.predict(X)
参考资料: