You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into some errors while running the code, which are summarized below:
#1from keras.layers.merge import _Merge ImportError: cannot import name '_Merge' from 'keras.layers.merge' python
Since Merge is not supported in Keras +2, I have made some modifications to the RandomWeightedAverage() class:
Old code:
fromkeras.layers.mergeimport_Mergeimportkeras.backendasKclassRandomWeightedAverage(_Merge):
"""Provides a (random) weighted average between real and generated image samples"""def_merge_function(self, inputs):
alpha=K.random_uniform((1024, 1))
return (alpha*inputs[0]) + ((1-alpha) *inputs[1])
Another error is related to the attribute "name" in line 69 of the CLSWGAN.py file. The solution is as simple as add a "_" before the attribute "name":
classificationLayer._name='modelClassifier'
#3 ValueError: Tried to convert 'x' to a tensor and failed. Error: None values not supported
This error was mentioned in the jacobgil/keras-grad-cam#17 (comment) issue, and appears to have been fixed by adding a piece of code to the LossFunctions.py file, namely the _compute_gradients(tensor, var_list) function and a small change to line 15.
importtensorflowastfdef_compute_gradients(tensor, var_list):
grads=tf.gradients(tensor, var_list)
return [gradifgradisnotNoneelsetf.zeros_like(var) forvar, gradinzip(var_list, grads)]
defgradient_penalty_loss(y_true, y_pred, averaged_samples):
""" Computes gradient penalty based on prediction and weighted real / fake samples """gradients=_compute_gradients(y_pred, [averaged_samples])[0]
(...)
The text was updated successfully, but these errors were encountered:
Hello,
I ran into some errors while running the code, which are summarized below:
#1 from keras.layers.merge import _Merge ImportError: cannot import name '_Merge' from 'keras.layers.merge' python
Since
Merge
is not supported in Keras +2, I have made some modifications to the RandomWeightedAverage() class:Old code:
Funtional code:
Then, you need to do a little change in line 48 of the CLSWGAN.py file:
FROM
TO
#2 AttributeError: Can't set the attribute "name"
Another error is related to the attribute "name" in line 69 of the CLSWGAN.py file. The solution is as simple as add a "_" before the attribute "name":
#3 ValueError: Tried to convert 'x' to a tensor and failed. Error: None values not supported
This error was mentioned in the jacobgil/keras-grad-cam#17 (comment) issue, and appears to have been fixed by adding a piece of code to the LossFunctions.py file, namely the
_compute_gradients(tensor, var_list)
function and a small change to line 15.The text was updated successfully, but these errors were encountered: