Constructs the model used by Estimator.
(features, labels, mode, params)
| 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, |
nothing calls this directly
no outgoing calls
no test coverage detected