tf_agents.utils.nest_utils.remove_singleton_batch_spec_dim
Stay organized with collections
Save and categorize content based on your preferences.
Look for spec
's shape, check that outer dim is 1, and remove it.
tf_agents.utils.nest_utils.remove_singleton_batch_spec_dim(
spec: tf.TypeSpec, outer_ndim: int
) -> tf.TypeSpec
If spec.shape[i] != 1
for any i in range(outer_ndim)
, we stop removing
singleton batch dimensions at i
and return what's left. This is necessary
to handle the outputs of inconsistent layers like tf.keras.layers.LSTM()
which may take as input (batch, time, dim) = (1, 1, Nin)
and emits only the
batch entry if time == 1
: output shape is (1, Nout)
. We log an error
in these cases.
Args |
spec
|
A tf.TypeSpec .
|
outer_ndim
|
The maximum number of outer singleton dims to remove.
|
Returns |
A tf.TypeSpec , the spec without its outer batch dimension(s).
|
Raises |
ValueError
|
If spec lacks a shape property.
|
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 2024-04-26 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 2024-04-26 UTC."],[],[]]