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

Convert cyclegan to keras-core #728

Merged
merged 3 commits into from
Aug 16, 2023
Merged

Conversation

freedomtan
Copy link
Contributor

  1. colab notebook
  2. keras to keras-core: the diff (565bdcb)

The CycleGan model has a custom tf-based train_step(), which its not backend-agnostic.

Copy link
Contributor

@fchollet fchollet left a 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!

from keras_core import layers
from keras_core import ops

import tensorflow # tf.GradientTap for training
Copy link
Contributor

Choose a reason for hiding this comment

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

Use import tensorflow as tf. Since this example is in the tensorflow/ folder there's no need to add comments to justify the TF import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


import tensorflow # tf.GradientTap for training
import tensorflow.data as tf_data
import tensorflow.image as tf_image
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise you can just use tf.data and tf.image directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

## Setup
"""

#!pip install -q git+https://github.com/keras-team/keras-core
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

[padding_width, padding_width],
[0, 0],
])
return ops.pad(input_tensor, ops.convert_to_tensor(padding_tensor), mode='reflect')
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure to run black on the file to format the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.

Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you! 👍

@fchollet fchollet merged commit 4062425 into keras-team:main Aug 16, 2023
@freedomtan freedomtan deleted the convert_cyclegan branch August 16, 2023 13:07
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