def test_compute_output_shape(self, get_circuit, output_dim, input_shape): """Test if the compute_output_shape() method performs correctly, i.e., that it replaces the last element in the input_shape tuple with the specified output_dim and that the output shape is of type tf.TensorShape""" c, w = get_circuit layer = KerasLayer(c, w, output_dim) assert layer.compute_output_shape(input_shape) == (input_shape[0], output_dim) assert isinstance(layer.compute_output_shape(input_shape), tf.TensorShape)
def test_compute_output_shape(self, get_circuit, output_dim): """Test that the compute_output_shape method returns the expected shape""" c, w = get_circuit layer = KerasLayer(c, w, output_dim) inputs = tf.keras.Input(shape=(2, )) inputs_shape = inputs.shape output_shape = layer.compute_output_shape(inputs_shape) assert output_shape.as_list() == [None, 1]