Exemplo n.º 1
0
    def Input(self, shape):
        """Builds an Input layer.

    Overrides the Keras application Input layer with one that uses a
    tf.placeholder_with_default instead of a tf.placeholder. This is necessary
    to ensure the application works when run on a TPU.

    Args:
      shape: A tuple of integers representing the shape of the input, which
        includes both spatial share and channels, but not the batch size.
        Elements of this tuple can be None; 'None' elements represent dimensions
        where the shape is not known.

    Returns:
      An input layer for the specified shape that internally uses a
      placeholder_with_default.
    """
        default_size = 224
        default_batch_size = 1
        shape = list(shape)
        default_shape = [default_size if dim is None else dim for dim in shape]

        input_tensor = tf.constant(0.0,
                                   shape=[default_batch_size] + default_shape)

        placeholder_with_default = tf.placeholder_with_default(
            input=input_tensor, shape=[None] + shape)
        return model_utils.input_layer(shape, placeholder_with_default)
    def Input(self, shape):
        """Builds an Input layer.

    Overrides the Keras application Input layer with one that uses a
    tf.placeholder_with_default instead of a tf.placeholder. This is necessary
    to ensure the application works when run on a TPU.

    Args:
      shape: The shape for the input layer to use. (Does not include a dimension
        for the batch size).
    Returns:
      An input layer for the specified shape that internally uses a
      placeholder_with_default.
    """
        default_size = 224
        default_batch_size = 1
        shape = list(shape)
        default_shape = [default_size if dim is None else dim for dim in shape]

        input_tensor = tf.constant(0.0,
                                   shape=[default_batch_size] + default_shape)

        placeholder_with_default = tf.placeholder_with_default(
            input=input_tensor, shape=[None] + shape)
        return model_utils.input_layer(shape, placeholder_with_default)