Warning: This project is deprecated. TensorFlow Addons has stopped development,
The project will only be providing minimal maintenance releases until May 2024. See the full
announcement here or on
github.
tfa.seq2seq.CustomSampler
Stay organized with collections
Save and categorize content based on your preferences.
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
)
Args |
initialize_fn
|
callable that returns (finished, next_inputs) for
the first iteration.
|
sample_fn
|
callable that takes (time, outputs, state) and emits
tensor sample_ids .
|
next_inputs_fn
|
callable that takes
(time, outputs, state, sample_ids) and emits
(finished, next_inputs, next_state) .
|
sample_ids_shape
|
Either a list of integers, or a 1-D Tensor of type
int32 , the shape of each value in the sample_ids batch.
Defaults to a scalar.
|
sample_ids_dtype
|
The dtype of the sample_ids tensor. Defaults to
int32.
|
Attributes |
batch_size
|
Batch size of tensor returned by sample .
Returns a scalar int32 tensor. The return value might not
available before the invocation of initialize(), in this case,
ValueError is raised.
|
sample_ids_dtype
|
DType of tensor returned by sample .
Returns a DType. The return value might not available before the
invocation of initialize().
|
sample_ids_shape
|
Shape of tensor returned by sample , excluding the batch dimension.
Returns a TensorShape . The return value might not available
before the invocation of initialize().
|
Methods
initialize
View source
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) .
|
View source
next_inputs(
time, outputs, state, sample_ids
)
Returns (finished, next_inputs, next_state)
.
sample
View source
sample(
time, outputs, state
)
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 2023-05-25 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-05-25 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-05-25 UTC."],[],[]]