MCPcopy Create free account
hub / github.com/google-research/language / model_fn

Method model_fn

language/realm/retrieval.py:399–415  ·  view source on GitHub ↗

Constructs the model used by Estimator.

(features, labels, mode, params)

Source from the content-addressed store, hash-verified

397 return dataset
398
399 def model_fn(features, labels, mode, params):
400 """Constructs the model used by Estimator."""
401 del labels, params
402 embedder_module = hub.Module(
403 spec=self._hub_module_spec, name='embedder', trainable=False)
404
405 # Remove the result_idx before feeding features to the module.
406 result_idx = features.pop('result_idx')
407
408 # [batch_size, embed_dim]
409 embeds = embedder_module(inputs=features, signature='projected')
410
411 return tf_estimator.tpu.TPUEstimatorSpec(
412 mode=mode, predictions={
413 'embeds': embeds,
414 'result_idx': result_idx
415 })
416
417 estimator = tf_estimator.tpu.TPUEstimator(
418 use_tpu=self._use_tpu,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected