-
Notifications
You must be signed in to change notification settings - Fork 60
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
Port to tensorflow 2 #25
Comments
The following minimal example gives another error message. The same code without ImportanceTraining works fine. from tensorflow import keras
import numpy as np
from importance_sampling.training import ImportanceTraining
num_x_features = 5
num_y_features = 2
x_train = np.random.uniform(0, 1, (100, num_x_features))
y_train = np.random.uniform(0, 1, (100, num_y_features))
model = keras.models.Sequential()
model.add(keras.layers.Dense(10, activation='relu', input_shape=(5,)))
model.add(keras.layers.Dense(10, activation='relu'))
model.add(keras.layers.Dense(num_y_features))
model.compile("adam", loss="mse")
history = ImportanceTraining(model).fit(
x_train, y_train,
batch_size=8,
epochs=5,
) Error message:
|
Will tensorflow 2 be supported at some point? I'd like to try this for my master's thesis and it would be nice to save the model in tensorflow 2 because keras will soon become obsolete. |
Hi, sorry for the late reply. It would be nice to update to tf 2. If instead of Feel free to dig in the code and ask question I will help as best I can. Cheers, |
It is not enough, unfortunately.
I've tried to upgrade the project automatically, but apparently there are some things that are not caught by the script. The point where I'm failing is in I can probably invest a bit time in porting this library, but I'd probably need some help. |
Try: from tensorflow.python.keras.callbacks import CallbackList |
I have made some formal changes to the code in my fork (4456623). There are still some things I couldn't solve yet:
I suspect most of the errors come from lines 262 and 384 I'd appreciate your feedback on the issue. |
@renatobellotti Sorry for the late reply, if you still need help with anything, let me know... |
I have not worked on this again, and my thesis does not allow me to spend more time ob this issue. I hope my contributions are at least a bit helpful. |
Hi everybody,
when applying importance sampling with Keras. |
At this point I would advise using TF 1 instead of 2. |
Dear Angelos,
thank you for replying so fast, but have u solved the problem bt using TF1?
Best regards
Maryam
…On Mon, Apr 27, 2020 at 1:09 AM Angelos Katharopoulos < ***@***.***> wrote:
At this point I would advise using TF 1 instead of 2.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#25 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJCCHE3PYMYHJJXSI63LY2LROSLZRANCNFSM4JMFHO4Q>
.
|
In my case it works with keras 2.3.1 and tf 2.1 however when the code was first developed there was tf 1 and keras 2 so if you are having issues, then try to use a tensorflow version < 2. |
Perhaps a clarification is needed. With the transition to tf2, the Keras API was merged into TensorFlow and is now a part of it. The standalone version of Keras will be discontinued. That means if this package cannot be run with tf2 only (without the separate Keras package), there will not be much future for it. I'm sorry to say this so directly, but I think this is a very important issue. |
Dear all,
have you found a solution? |
@maryam2013 I am not using this package because I'm using TF2, but perhaps the developers need your version of Keras to help you. |
@renatobellotti I am sorry if I came across as dismissive. I agree 100% that we need to move to TF2. However, I do not think that it would be trivial. For instance, since TF now is eager by default maybe we can completely redesign and simplify the library. There is a lot of magic happening behind the scenes in the current version so that we can recreate the training experience one has with Keras. I do not see myself doing this kind of redesign in the coming weeks or months and I realize that it will probably hurt the adoption of the library quite a lot. |
@angeloskath Thank you for your answer. I formulated my post harsher than intended, sorry for that. Of course I understand that time is always a limited resource. If you decide in the future to do a rewrite, please let me know, perhaps I can help, at least with testing. |
Hello, could anyone supply the precise tensorflow and keras versions used to successfully run examples/mnist_mlp.py with args.importance_training=True ? The _augment_model method in model_wrappers.py is problematic (at least with tensorflow > 2.0) since that method calls get_output before corresponding layers are used: _get_node_attribute_at_index: Thanks for your help! |
Here is a working example (as of earlier this year): See in general that repo: |
Perhaps this issue could be closed once the authors create a proper setup.py with explicit install requirements that work in this repo. |
Running this module using tensorflow 2.0.0 yields an error:
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
Are there any plans to port the library to tensorflow 2.0.0?
Perhaps all you have to do is change
import keras
tofrom tensorflow import keras
and perhaps use fully qualified names when using layers...The text was updated successfully, but these errors were encountered: