在链接之后,代码显示如果没有可用的 TPU,Estimator 将回退到 CPU 或 GPU。只要确保在它出现的任何地方都设置了use_tpu = False:
# If TPU is not available, this will fall back to normal Estimator on CPU
# or GPU.
estimator = tf.contrib.tpu.TPUEstimator(
use_tpu=False,
model_fn=model_fn,
config=run_config,
predict_batch_size=BATCH_SIZE,
train_batch_size=BATCH_SIZE)
也直接在model_fn_builder 调用中。像这样:
model_fn = model_fn_builder(
bert_config=bert_config,
init_checkpoint=INIT_CHECKPOINT,
layer_indexes=layer_indexes,
use_tpu=False,
use_one_hot_embeddings=True)