tf.compat.v1.keras.utils.DeterministicRandomTestTool
Stay organized with collections
Save and categorize content based on your preferences.
DeterministicRandomTestTool is a testing tool.
tf.compat.v1.keras.utils.DeterministicRandomTestTool(
seed: int = 42, mode='constant'
)
This tool is used to validate random number generation semantics match between
TF1.x graphs/sessions and eager execution.
This is useful when you are migrating from TF 1.x to TF2 and need to make sure
your computation is still happening correctly along the way. See the
validating correctness migration guide for more info :
https://www.tensorflow.org/guide/migrate/validate_correctness
The following DeterministicRandomTestTool object provides a context manager
scope() that can make stateful random operations use the same seed across both
TF1 graphs/sessions and eager execution,The tool provides two testing modes:
- constant which uses the same seed for every single operation no matter how
many times it has been called and,
- num_random_ops which uses the number of previously-observed stateful random
operations as the operation seed.
The num_random_ops mode serves as a more sensitive validation check than the
constant mode. It ensures that the random numbers initialization does not get
accidentaly reused.(for example if several weights take on the same
initializations), you can use the num_random_ops mode to avoid this. In the
num_random_ops mode, the generated random numbers will depend on the ordering
of random ops in the program.
This applies both to the stateful random operations used for creating and
initializing variables, and to the stateful random operations used in
computation (such as for dropout layers).
Attributes |
operation_seed
|
|
Methods
scope
View source
scope()
set random seed.
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. Some content is licensed under the numpy license.
Last updated 2022-09-07 UTC.
[null,null,["Last updated 2022-09-07 UTC."],[],[],null,["# tf.compat.v1.keras.utils.DeterministicRandomTestTool\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/v2.9.0/keras/legacy_tf_layers/migration_utils.py#L15-L103) |\n\nDeterministicRandomTestTool is a testing tool. \n\n tf.compat.v1.keras.utils.DeterministicRandomTestTool(\n seed: int = 42, mode='constant'\n )\n\nThis tool is used to validate random number generation semantics match between\nTF1.x graphs/sessions and eager execution.\n\nThis is useful when you are migrating from TF 1.x to TF2 and need to make sure\nyour computation is still happening correctly along the way. See the\nvalidating correctness migration guide for more info :\n\u003chttps://www.tensorflow.org/guide/migrate/validate_correctness\u003e\n\nThe following DeterministicRandomTestTool object provides a context manager\nscope() that can make stateful random operations use the same seed across both\nTF1 graphs/sessions and eager execution,The tool provides two testing modes:\n\n- constant which uses the same seed for every single operation no matter how many times it has been called and,\n- num_random_ops which uses the number of previously-observed stateful random operations as the operation seed. The num_random_ops mode serves as a more sensitive validation check than the constant mode. It ensures that the random numbers initialization does not get accidentaly reused.(for example if several weights take on the same initializations), you can use the num_random_ops mode to avoid this. In the num_random_ops mode, the generated random numbers will depend on the ordering of random ops in the program.\n\nThis applies both to the stateful random operations used for creating and\ninitializing variables, and to the stateful random operations used in\ncomputation (such as for dropout layers).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|------------------|---------------|\n| `operation_seed` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `scope`\n\n[View source](https://github.com/keras-team/keras/tree/v2.9.0/keras/legacy_tf_layers/migration_utils.py#L65-L103) \n\n scope()\n\nset random seed."]]