libspn-keras icon indicating copy to clipboard operation
libspn-keras copied to clipboard

Example Image Completion "Value Error"

Open daniel-redder opened this issue 2 years ago • 1 comments

The unedited colab for image completion throws a value error on the last block.

omitting  top

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-8-3ecd981d1ef5> in <module>()
     45     raise ValueError("We have a problem")
     46 
---> 47 eval(completion_model, test_x, 'top')
     48 eval(completion_model, test_x, 'bottom')
     49 eval(completion_model, test_x, 'left')

2 frames

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
   1127           except Exception as e:  # pylint:disable=broad-except
   1128             if hasattr(e, "ag_error_metadata"):
-> 1129               raise e.ag_error_metadata.to_exception(e)
   1130             else:
   1131               raise

ValueError: in user code:

    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1366, in test_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1356, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1349, in run_step  **
        outputs = model.test_step(data)
    File "/usr/local/lib/python3.7/dist-packages/libspn_keras/models/sequential_spn.py", line 256, in test_step
        return super(SequentialSumProductNetwork, self).test_step(data)
    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1303, in test_step
        y_pred = self(x, training=False)
    File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py", line 199, in assert_input_compatibility
        raise ValueError(f'Layer "{layer_name}" expects {len(input_spec)} input(s),'

    ValueError: Layer "sequential_sum_product_network_1" expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, 64, 64, 1) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None, 64, 64, 1) dtype=bool>]
![Screenshot from 2022-01-19 14-41-52](https://user-images.githubusercontent.com/56208568/150202578-a85becae-3bb9-4951-8410-9233d7cb63c9.png)

daniel-redder avatar Jan 19 '22 19:01 daniel-redder

For now this can be solved by the following. Comment out the exception in keras/engine/input_spec.py This isn't a optimal way to solve this but it seems to let us ignore the problem created by providing the evidence mask in this way.

daniel-redder avatar Feb 07 '22 18:02 daniel-redder