model_fn
closure for TPUEstimator
Returns model_fn
closure, which is an input to TPUEstimator
.
This function is similar to model_fn_builder
from run_classifier.R.
(RBERT issue #28.)
.model_fn_builder_EF(bert_config, init_checkpoint, layer_indexes, use_tpu)
BertConfig
instance.
Character; path to the checkpoint directory, plus checkpoint name stub (e.g. "bert_model.ckpt"). Path must be absolute and explicit, starting with "/".
Integer list; indexes (positive, or negative counting back from the end) indicating which layers to extract as "output features". (It needs to be specified here because we get them back as the model "predictions".)
Logical; whether to use TPU.
model_fn
closure for TPUEstimator
.
The model_fn
function takes four parameters:
A list (or similar structure) that contains objects such as
input_ids
, input_mask
, tokens
, and
input_type_ids
. These objects will be inputs to the
create_model
function.
Not used in this function, but presumably we need to keep this slot here.
Character; value such as "train", "infer", or "eval".
Not used in this function, but presumably we need to keep this slot here.
The output of model_fn
is the result of a
tf$contrib$tpu$TPUEstimatorSpec
call.