tf.contrib.seq2seq.InferenceHelper
Stay organized with collections
Save and categorize content based on your preferences.
A helper to use during inference with a custom sampling function.
Inherits From: Helper
tf.contrib.seq2seq.InferenceHelper(
sample_fn, sample_shape, sample_dtype, start_inputs, end_fn, next_inputs_fn=None
)
Args |
sample_fn
|
A callable that takes outputs and emits tensor sample_ids .
|
sample_shape
|
Either a list of integers, or a 1-D Tensor of type int32 ,
the shape of the each sample in the batch returned by sample_fn .
|
sample_dtype
|
the dtype of the sample returned by sample_fn .
|
start_inputs
|
The initial batch of inputs.
|
end_fn
|
A callable that takes sample_ids and emits a bool vector
shaped [batch_size] indicating whether each sample is an end token.
|
next_inputs_fn
|
(Optional) A callable that takes sample_ids and returns
the next batch of inputs. If not provided, sample_ids is used as the
next batch of inputs.
|
Attributes |
batch_size
|
Batch size of tensor returned by sample .
Returns a scalar int32 tensor.
|
sample_ids_dtype
|
DType of tensor returned by sample .
Returns a DType.
|
sample_ids_shape
|
Shape of tensor returned by sample , excluding the batch dimension.
Returns a TensorShape .
|
Methods
initialize
View source
initialize(
name=None
)
Returns (initial_finished, initial_inputs)
.
View source
next_inputs(
time, outputs, state, sample_ids, name=None
)
Returns (finished, next_inputs, next_state)
.
sample
View source
sample(
time, outputs, state, name=None
)
Returns sample_ids
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.seq2seq.InferenceHelper\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L681-L736) |\n\nA helper to use during inference with a custom sampling function.\n\nInherits From: [`Helper`](../../../tf/contrib/seq2seq/Helper) \n\n tf.contrib.seq2seq.InferenceHelper(\n sample_fn, sample_shape, sample_dtype, start_inputs, end_fn, next_inputs_fn=None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `sample_fn` | A callable that takes `outputs` and emits tensor `sample_ids`. |\n| `sample_shape` | Either a list of integers, or a 1-D Tensor of type `int32`, the shape of the each sample in the batch returned by `sample_fn`. |\n| `sample_dtype` | the dtype of the sample returned by `sample_fn`. |\n| `start_inputs` | The initial batch of inputs. |\n| `end_fn` | A callable that takes `sample_ids` and emits a `bool` vector shaped `[batch_size]` indicating whether each sample is an end token. |\n| `next_inputs_fn` | (Optional) A callable that takes `sample_ids` and returns the next batch of inputs. If not provided, `sample_ids` is used as the next batch of inputs. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------------|------------------------------------------------------------------------------------------------------|\n| `batch_size` | Batch size of tensor returned by `sample`. \u003cbr /\u003e Returns a scalar int32 tensor. |\n| `sample_ids_dtype` | DType of tensor returned by `sample`. \u003cbr /\u003e Returns a DType. |\n| `sample_ids_shape` | Shape of tensor returned by `sample`, excluding the batch dimension. \u003cbr /\u003e Returns a `TensorShape`. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `initialize`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L721-L723) \n\n initialize(\n name=None\n )\n\nReturns `(initial_finished, initial_inputs)`.\n\n### `next_inputs`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L729-L736) \n\n next_inputs(\n time, outputs, state, sample_ids, name=None\n )\n\nReturns `(finished, next_inputs, next_state)`.\n\n### `sample`\n\n[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/seq2seq/python/ops/helper.py#L725-L727) \n\n sample(\n time, outputs, state, name=None\n )\n\nReturns `sample_ids`."]]