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

Change imports to include tf.keras #83

Closed
wants to merge 3 commits into from
Closed

Change imports to include tf.keras #83

wants to merge 3 commits into from

Conversation

psomers3
Copy link
Contributor

@psomers3 psomers3 commented Oct 11, 2019

This is a proposed solution to getting rid of the tensor flow 2.0 branch. It may not be the most intuitive, but it works nicely and there is only one TCN class that is common between the two imports.

Now works with
from tcn.keras import TCN, compiled_tcn
and/or
from tcn.tensorflow import TCN, compiled_tcn

@psomers3
Copy link
Contributor Author

To be clear, these changes won't error out if either keras or tensorflow (or both) are not installed. It will print out and tell you, though.

@philipperemy
Copy link
Owner

Ok going to have a look :)

@philipperemy
Copy link
Owner

philipperemy commented Oct 15, 2019

Just for info, with the current master, tensorflow 2.0 + latest keras works:

virtualenv -p python3.6 -q venv-tf2.0
source venv-tf2.0/bin/activate
pip install -r requirements.txt
pip install tensorflow==2.0.0

pip install -e .

python sequential.py

When you say tensorflow 2.0, you mean without installing Keras right?

@philipperemy
Copy link
Owner

philipperemy commented Oct 15, 2019

And this would not work? https://github.com/philipperemy/keras-tcn/pull/74/files
Just a simple try catch.

@psomers3
Copy link
Contributor Author

Well, with the try-catch, doesn't it make it almost impossible to use pure keras with a different backend if you have tensor flow installed? That was the only reason I did it like this. Also, I seem to have a weird issue now with the imports using importlib, so maybe a simple try catch there is better.

@philipperemy
Copy link
Owner

Yeah I'd be in favor of a simpler solution like a very trivial try catch.

@psomers3
Copy link
Contributor Author

But still set up the way I did it? Or like #74?

@philipperemy
Copy link
Owner

I still feel like the try catch solution is more elegant.

@psomers3
Copy link
Contributor Author

I agree, but should the try catch be in init.py and have submodules as I did it, or should we just make sure #74 works well and use that?

@philipperemy
Copy link
Owner

I don't have a clear opinion on it. What would be the most pythonic solution in your opinion?

@psomers3
Copy link
Contributor Author

:D well, to be honest I‘m still pretty new to python, so I wouldn‘t trust my thoughts on pythonic. If people use this with other backends AND have tensorflow installed, then #74 wouldn‘t work for them. That‘s the only reason I proposed this. I‘d be open to calling in a more experienced pythoner for their opinion because I am truly curious if what I‘ve done is a good idea. Know anyone? :)

@philipperemy
Copy link
Owner

I'd say the simple with the try catch is probably the best at the moment. I'm not a big fan of dynamic imports in python :)

@philipperemy
Copy link
Owner

See #94

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