bstriner / keras-adversarial

Keras Generative Adversarial Networks
MIT License
867 stars 231 forks source link

Issues with Keras 2.1.5 #56

Open artusi-a opened 6 years ago

artusi-a commented 6 years ago

It seems that there are some issues with the latest version of Keras 2.1.5

1) in adversial_model internal_input_shapes and internal_output_shapes need to be corrected to _internal_input_shapes, _internal_output_shapes, this is easy to fix.

2) However the following error needs some more careful attention File "/Users/MacBookPro1/Work/Code/Python/PycharmProjects/GANs/venv/lib/python3.6/site-packages/keras/engine/training.py", line 1132, in _fit_loop stateful_metrics=self.stateful_metric_names)] AttributeError: 'AdversarialModel' object has no attribute 'stateful_metric_names'

Any help? is this going to be fixed? Thanks

KinWaiCheuk commented 6 years ago

For your question 2, I have a quick fix, but not sure if it works for you.

In the adversarial_model.py, there is a block of code that fixes keras 2's compatibility issue, at around line 128.

        # Keras-2
        self._feed_loss_fns = self.loss_functions
        self._feed_inputs = self.inputs
        self._feed_input_names = self.input_names
        self._feed_input_shapes = self._feed_input_shapes
        self._feed_outputs = self.outputs
        self._feed_output_names = self.output_names
        self._feed_output_shapes = self._feed_output_shapes
        self._feed_sample_weights = self.sample_weights
        self._feed_sample_weight_modes = self.sample_weight_modes

Try adding the following codes to the block.

        self._feed_targets = self.targets
        self.metrics = model.metrics_tensors
        self.stateful_metric_names = self.metrics_names
artusi-a commented 6 years ago

Ok I will do and let you know if it works. Thanks a lot

Zooshi commented 6 years ago

I do not see the codeblock in the adversarial_model.py file

KinWaiCheuk commented 6 years ago

Then your adversarial_model.py is not up-to-date. Download the latest version, and you will see the following code block. codebloack

Then replace the code with the following:

        # Keras-2
        self._feed_loss_fns = self.loss_functions
        self._feed_inputs = self.inputs
        self._feed_input_names = self.input_names
        self._feed_input_shapes = self._feed_input_shapes #error fix
        self._feed_outputs = self.outputs
        self._feed_output_names = self.output_names
        self._feed_output_shapes = self._feed_output_shapes #error fix
        self._feed_sample_weights = self.sample_weights
        self._feed_sample_weight_modes = self.sample_weight_modes

        self._feed_targets = self.targets
        self.metrics = model.metrics_tensors
        self.stateful_metric_names = self.metrics_names