View source on GitHub |
Base abstract class that allows the user to customize sampling.
Inherits From: Sampler
tfa.seq2seq.CustomSampler(
initialize_fn: tfa.types.Initializer
,
sample_fn: Callable,
next_inputs_fn: Callable,
sample_ids_shape: Optional[TensorLike] = None,
sample_ids_dtype: tfa.types.AcceptableDTypes
= None
)
Methods
initialize
initialize(
inputs, **kwargs
)
initialize the sampler with the input tensors.
This method must be invoked exactly once before calling other methods of the Sampler.
Args | |
---|---|
inputs
|
A (structure of) input tensors, it could be a nested tuple or a single tensor. |
**kwargs
|
Other kwargs for initialization. It could contain tensors like mask for inputs, or non tensor parameter. |
Returns | |
---|---|
(initial_finished, initial_inputs) .
|
next_inputs
next_inputs(
time, outputs, state, sample_ids
)
Returns (finished, next_inputs, next_state)
.
sample
sample(
time, outputs, state
)
Returns sample_ids
.