-
Notifications
You must be signed in to change notification settings - Fork 118
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
Small ops fixes for Torch unit tests #316
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@@ -416,6 +416,7 @@ def mish(x): | |||
|
|||
- [Misra, 2019](https://arxiv.org/abs/1908.08681) | |||
""" | |||
x = backend.convert_to_tensor(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is torch related, can we move it to the torch backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling mish in activations.py does x * backend.nn.tanh(backend.nn.softplus(x)) a few lines above this, and this will multiply a numpy array (x) by a Torch tensor, which is not allowed. The conversion to a tensor for x (first arg) must therefore be done here.
keras_core/utils/progbar.py
Outdated
@@ -160,7 +161,9 @@ def update(self, current, values=None, finalize=None): | |||
info += f" - {k}:" | |||
if isinstance(self._values[k], list): | |||
avg = np.mean( | |||
self._values[k][0] / max(1, self._values[k][1]) | |||
backend.convert_to_numpy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Haifeng has already provided a fix that should make this change unnecessary (earlier today)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, reverted thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This PR contains some small ops fixes for Torch unit tests, particularly those relating to incompatibility with numpy ops. Subsequent PRs will contain remaining fixes.