@classmethod<EOL><INDENT>def from_keras(cls, model, bounds, input_shape=None,<EOL>channel_axis=<NUM_LIT:3>, preprocessing=(<NUM_LIT:0>, <NUM_LIT:1>)):<DEDENT>
import tensorflow as tf<EOL>if input_shape is None:<EOL><INDENT>try:<EOL><INDENT>input_shape = model.input_shape[<NUM_LIT:1>:]<EOL><DEDENT>except AttributeError:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>with tf.keras.backend.get_session().as_default():<EOL><INDENT>inputs = tf.placeholder(tf.float32, (None,) + input_shape)<EOL>logits = model(inputs)<EOL>return cls(inputs, logits, bounds=bounds,<EOL>channel_axis=channel_axis, preprocessing=preprocessing)<EOL><DEDENT>
Alternative constructor for a TensorFlowModel that
        accepts a `tf.keras.Model` instance.

        Parameters
        ----------
        model : `tensorflow.keras.Model`
            A `tensorflow.keras.Model` that accepts a single input tensor
            and returns a single output tensor representing logits.
        bounds : tuple
            Tuple of lower and upper bound for the pixel values, usually
            (0, 1) or (0, 255).
        input_shape : tuple
            The shape of a single input, e.g. (28, 28, 1) for MNIST.
            If None, tries to get the the shape from the model's
            input_shape attribute.
        channel_axis : int
            The index of the axis that represents color channels.
        preprocessing: 2-element tuple with floats or numpy arrays
            Elementwises preprocessing of input; we first subtract the first
            element of preprocessing from the input and then divide the input
            by the second element.