dot-model_fn_builder_EF: Define 'model_fn' closure for 'TPUEstimator'

.model_fn_builder_EFR Documentation

Define model_fn closure for TPUEstimator

Description

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.)

Usage

.model_fn_builder_EF(bert_config, init_checkpoint, layer_indexes, use_tpu)

Arguments

bert_config

BertConfig instance.

init_checkpoint

Character; path to the checkpoint directory, plus checkpoint name stub (e.g. "bert_model.ckpt"). Path must be absolute and explicit, starting with "/".

layer_indexes

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".)

use_tpu

Logical; whether to use TPU.

Details

The model_fn function takes four parameters:

features

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.

labels

Not used in this function, but presumably we need to keep this slot here.

mode

Character; value such as "train", "infer", or "eval".

params

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.

Value

model_fn closure for TPUEstimator.


jonathanbratt/RBERT documentation built on Jan. 26, 2023, 4:15 p.m.