Tensorflow TPU估计器中的静音记录
我正在使用BERTTensorflow TPU估计器中的静音记录,tensorflow,logging,tensorflow-estimator,verbosity,tpu,Tensorflow,Logging,Tensorflow Estimator,Verbosity,Tpu,我正在使用BERTrun_分类器和tensorflowTPUEstimator,每次我训练我的模型或使用估计器预测时,我都会在屏幕上打印太多日志信息。我怎样才能摆脱这些信息。以下行打印百万次: INFO:tensorflow:Dequeue next (1) batch(es) of data from outfeed. I0423 15:45:17.093261 140624241985408 tpu_estimator.py:540] Dequeue next (1) batch(es) o
run_分类器
和tensorflowTPUEstimator
,每次我训练我的模型或使用估计器预测时,我都会在屏幕上打印太多日志信息。我怎样才能摆脱这些信息。以下行打印百万次:
INFO:tensorflow:Dequeue next (1) batch(es) of data from outfeed.
I0423 15:45:17.093261 140624241985408 tpu_estimator.py:540] Dequeue next (1) batch(es) of data from outfeed.
此外,下面这行代码在我的屏幕上被写入了数百万次(尽管没有问题,并且模型使用TPU进行了正确的训练)
这是产生这种冗长的代码:
from bert import run_classifier
estimator = tf.contrib.tpu.TPUEstimator(
use_tpu=True,
model_fn=model_fn,
config=get_run_config(OUTPUT_DIR),
train_batch_size=TRAIN_BATCH_SIZE,
eval_batch_size=EVAL_BATCH_SIZE,
predict_batch_size=PREDICT_BATCH_SIZE,
)
input_features = run_classifier.convert_examples_to_features(prediction_examples, label_list, MAX_SEQ_LENGTH, tokenizer)
predict_input_fn = run_classifier.input_fn_builder(features=input_features, seq_length=MAX_SEQ_LENGTH, is_training=False, drop_remainder=True)
predictions = estimator.predict(predict_input_fn)
我怎样才能要求模型不打印它们呢?您应该能够使用
在main()
方法的第一行,详细级别v
可以是:
_level_names = {
FATAL: 'FATAL',
ERROR: 'ERROR',
WARN: 'WARN',
INFO: 'INFO',
DEBUG: 'DEBUG',
}
其中
v=tf.logging.FATAL
将打印最少的日志 谢谢!成功了。但是没有办法得到信息,但没有错误?我的意思是,如果将日志详细度设置为INFO,那么输出中也会包含错误?这是出于设计。错误是比信息更严重的情况。当较低级别的日志记录处于启用状态时,所有较高级别的日志记录也处于启用状态。
tf.logging.set_verbosity(v)
_level_names = {
FATAL: 'FATAL',
ERROR: 'ERROR',
WARN: 'WARN',
INFO: 'INFO',
DEBUG: 'DEBUG',
}