Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Making keras-contrib compatible with tf.keras #387

Merged

Conversation

gabrieldemarmiesse
Copy link
Contributor

@gabrieldemarmiesse gabrieldemarmiesse commented Dec 30, 2018

closes #376

@gabrieldemarmiesse
Copy link
Contributor Author

It seems travis is not notified anymore.

@gabrieldemarmiesse gabrieldemarmiesse force-pushed the tf_keras_again branch 4 times, most recently from b301941 to 1edb648 Compare December 30, 2018 12:09
@gabrieldemarmiesse
Copy link
Contributor Author

@farizrahman4u could you review this PR when/if you have the time? Thanks in advance.

CONTRIBUTING.md Outdated
python convert_to_tf_keras.py --revert
```

Not that you are strongly encouraged to commit your code before in case the parsing would go wrong. To discard all the changes you made since the previous commit:
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Note that

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want to encourage users to use the git reset --hard ? Something like git stash would be less definitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, the method I describe here is very brittle. This is because my knowledge of GIT is quite limited. Do you have a workflow in mind which would be cleaner and more robust?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would encourage to do a soft reset with git reset HEAD^ and then stash all the current untracked modifications with git stash. In this case, you can retrieve those untracked modifications with git stash pop

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 for the tip!

('from keras ', 'from tensorflow.keras ')]


def replace_imports(file_path, revert):
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be more prudent to add a test, to make sure the created file is as expected (like we do with generated docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already run all the tests with the generated files. Do you have a specific test in mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ho, I see what you mean. I'm not in favor of including tests at running time (except for catching user errors) because this will complexify the codebase. Separating the tests and the implementation allow for a better readability. And when tests fail, we know exactly which use case caused it. It's more extensible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RaphaelMeudec do you have any simple tests in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gabrieldemarmiesse What I had in mind is :

  • Create an asset file in the test directory, and apply replace_imports to it. Make sure that there is an output file created, and that the return value of the function is approriate
  • Apply in reverse the same function to make sure generated file matches the original file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test in the same file (we don't have a choice, we can't import the function directly). And added the command to run it in travis.

@gabrieldemarmiesse gabrieldemarmiesse dismissed farizrahman4u’s stale review February 6, 2019 09:43

farizaman4u agreed with the current plan.

@gabrieldemarmiesse
Copy link
Contributor Author

I seems that tensorflow.keras.backend doesn't have local_conv_1d and local_conv2d.

@gabrieldemarmiesse gabrieldemarmiesse changed the title Tf keras again Making keras-contrib compatible with tf.keras Feb 10, 2019
CONTRIBUTING.md Outdated
@@ -95,7 +95,10 @@ python convert_to_tf_keras.py --revert

Note that you are strongly encouraged to commit your code before in case the parsing would go wrong. To discard all the changes you made since the previous commit:
```
git reset --hard
# saves a copy of your current codebase in the git stash and comes back to the previous commit
git reset && git stash
Copy link
Contributor

Choose a reason for hiding this comment

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

Using git stash is enough, you don't need the git reset doc

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

@RaphaelMeudec
Copy link
Contributor

@gabrieldemarmiesse Final note on your PR, also I explained how I imagined the tests for the transformation.

@gabrieldemarmiesse
Copy link
Contributor Author

Any more comments about this?

Copy link
Contributor

@RaphaelMeudec RaphaelMeudec left a comment

Choose a reason for hiding this comment

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

@gabrieldemarmiesse
Copy link
Contributor Author

I'll merge now. I'll open an issue in the tensorflow repo about the input of the build function.

@gabrieldemarmiesse gabrieldemarmiesse merged commit fff2642 into keras-team:master Feb 15, 2019
@gabrieldemarmiesse
Copy link
Contributor Author

Opened tensorflow/tensorflow#25790 to track the weird incompatibility. I hope it'll go away at some point.

SriRangaTarun added a commit to SriRangaTarun/keras-contrib that referenced this pull request Feb 16, 2019
Making keras-contrib compatible with tf.keras (keras-team#387)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Any plan to make the repo usable for tf.keras ?
3 participants