Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A fix for seed attribute in the keras random normal generator #2126

Merged
merged 8 commits into from
Mar 16, 2023

Conversation

inonbe
Copy link
Contributor

@inonbe inonbe commented Feb 23, 2023

The seed attribute was not passing to the converted onnx model due to that it exists in "seed2" attribute instead of "seed" and its internal type is Integer and not float.
Currently there is no impact on existing unit_tests ("test_auto_encoder" for example) or need for new unit test
since still the random generator behaves differently on various engines.

…d field was not passing to the converted onnx model due to that it exists in seed2 attribute instead of seed and its type is Integer and not float.

Signed-off-by: inonbe <inonb@waves.com>
@@ -88,8 +88,8 @@ def version_9(cls, ctx, node, **kwargs):
if node.inputs[0].is_const():
cls.version_1(ctx, node, **kwargs)
else:
seed = node.get_attr("seed")
node.set_attr("seed", float(seed.f))
seed = node.get_attr("seed2")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to also update this for version_1(line 63)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @fatcat-z you're quite right, ill update version_1 as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused: is this behavior (using seed2 instead of seed) same among different TF versions? Did it change after one of tf version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I've seen and tested, version_1 behaviour is also relevant for TF version.2
when the random generator dim/shape are constant and not derived from the data
batch size or any other dependent size.

I'm checking with TF V1 whether it was changed.

Copy link
Collaborator

@fatcat-z fatcat-z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contributions!

@fatcat-z fatcat-z enabled auto-merge (squash) March 16, 2023 07:33
@fatcat-z fatcat-z merged commit 5f918ab into onnx:main Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants