Closed peterhsu2018 closed 6 years ago
Hi @peterhsu2018 . Sorry, keras-vis was not released that this problem was fixed. So please directly re-install keras-vis via github.
pip install git+https://github.com/raghakot/keras-vis.git -U
This issue should have fixed by PR #120 , so I'll close this. But if I made mistaken, please feel free to reopen.
Thanks!
Hi @peterhsu2018 . Sorry, keras-vis was not released that this problem was fixed. So please directly re-install keras-vis via github.
pip install git+https://github.com/raghakot/keras-vis.git -U
This issue should have fixed by PR #120 , so I'll close this. But if I made mistaken, please feel free to reopen.
Thanks!
Hi @keisen This is helpful for me Thanks a lot!
Hi @peterhsu2018 . Sorry, keras-vis was not released that this problem was fixed. So please directly re-install keras-vis via github.
pip install git+https://github.com/raghakot/keras-vis.git -U
This issue should have fixed by PR #120 , so I'll close this. But if I made mistaken, please feel free to reopen.
Thanks!
This response by @keisen worked for me too, but only after doing a fresh re-install
pip uninstall keras-vis pip install git+https://github.com/raghakot/keras-vis.git -U
-then refresh env in jupyter notebook and done! It should be working =)
Hello @peterhsu2018 @keisen
It worked for me after reinstalling keras and tensorflow.
Many thanks for your help !
Installed keras-vis from the github, and reinstalled both keras and tensorflow. I am still getting this error.
from tensorflow.keras import layers, models, datasets, utils
inp = layers.Input((28,28))
x = layers.Flatten()(inp)
x = layers.BatchNormalization()(x)
x = layers.Dense(1024, activation="relu")(x)
x = layers.Dense(512, activation="relu")(x)
x = layers.Dense(128, activation="relu")(x)
oup = layers.Dense(10, activation="softmax")(x)
model = models.Model(inputs=inp, outputs=oup)
model.compile("rmsprop", loss="categorical_crossentropy", metrics=["accuracy"])
(X_train,y_train),(X_test,y_test) = datasets.fashion_mnist.load_data()
y_train = utils.to_categorical(y_train)
y_test = utils.to_categorical(y_test)
model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=1)
from vis import visualization, utils
from keras import activations
layer_idx = -1
model.layers[layer_idx].activation = activations.linear
model.save("tmp.model")
model = models.load_model("tmp.model")
grads = visualization.visualize_saliency(model, 2,
filter_indices=0,
seed_input=X_test[0])
Installed keras-vis from the github, and reinstalled both keras and tensorflow. I am still getting this error.
from tensorflow.keras import layers, models, datasets, utils inp = layers.Input((28,28)) x = layers.Flatten()(inp) x = layers.BatchNormalization()(x) x = layers.Dense(1024, activation="relu")(x) x = layers.Dense(512, activation="relu")(x) x = layers.Dense(128, activation="relu")(x) oup = layers.Dense(10, activation="softmax")(x) model = models.Model(inputs=inp, outputs=oup) model.compile("rmsprop", loss="categorical_crossentropy", metrics=["accuracy"]) (X_train,y_train),(X_test,y_test) = datasets.fashion_mnist.load_data() y_train = utils.to_categorical(y_train) y_test = utils.to_categorical(y_test) model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=1) from vis import visualization, utils from keras import activations layer_idx = -1 model.layers[layer_idx].activation = activations.linear model.save("tmp.model") model = models.load_model("tmp.model") grads = visualization.visualize_saliency(model, 2, filter_indices=0, seed_input=X_test[0])
First, remove all vis packages by the following code,
pip uninstall vis
pip uninstall keras-vis
pip uninstall keras-vis-temp
Then install keras vis,
pip install git+https://github.com/raghakot/keras-vis.git -U
run example/resnet/attention.ipynb and change to the model with my custom resnet50 like this: model_path = os.path.join('../../../saved_models', 'res50transfer_learning.h5') model = load_model(model_path)
layer_idx = utils.find_layer_idx(model, 'dense_1')
my environment Keras 2.2.2 Tensorflow 1.10 Keras-vis 0.4.1