MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / InputLayer

Class InputLayer

tensorflow/python/keras/engine/input_layer.py:33–159  ·  view source on GitHub ↗

Layer to be used as an entry point into a Network (a graph of layers). It can either wrap an existing tensor (pass an `input_tensor` argument) or create a placeholder tensor (pass arguments `input_shape`, and optionally, `dtype`). It is generally recommend to use the functional layer API v

Source from the content-addressed store, hash-verified

31
32@keras_export('keras.layers.InputLayer')
33class InputLayer(base_layer.Layer):
34 """Layer to be used as an entry point into a Network (a graph of layers).
35
36 It can either wrap an existing tensor (pass an `input_tensor` argument)
37 or create a placeholder tensor (pass arguments `input_shape`, and
38 optionally, `dtype`).
39
40 It is generally recommend to use the functional layer API via `Input`,
41 (which creates an `InputLayer`) without directly using `InputLayer`.
42
43 This class can create placeholders for tf.Tensors, tf.SparseTensors, and
44 tf.RaggedTensors by choosing 'sparse=True' or 'ragged=True'.
45
46 Arguments:
47 input_shape: Shape tuple (not including the batch axis), or `TensorShape`
48 instance (not including the batch axis).
49 batch_size: Optional input batch size (integer or None).
50 dtype: Datatype of the input.
51 input_tensor: Optional tensor to use as layer input
52 instead of creating a placeholder.
53 sparse: Boolean, whether the placeholder created is meant to be sparse.
54 ragged: Boolean, whether the placeholder created is meant to be ragged.
55 In this case, values of 'None' in the 'shape' argument represent
56 ragged dimensions. For more information about RaggedTensors, see
57 https://www.tensorflow.org/guide/ragged_tensors.
58 name: Name of the layer (string).
59 """
60
61 def __init__(self,
62 input_shape=None,
63 batch_size=None,
64 dtype=None,
65 input_tensor=None,
66 sparse=False,
67 name=None,
68 ragged=False,
69 **kwargs):
70 strategy = distribution_strategy_context.get_strategy()
71 if strategy and batch_size is not None and \
72 distributed_training_utils.global_batch_size_supported(strategy):
73 if batch_size % strategy.num_replicas_in_sync != 0:
74 raise ValueError('The `batch_size` argument value {} cannot be '
75 'divisible by number of replicas {}'.format(
76 batch_size, strategy.num_replicas_in_sync))
77 batch_size = batch_size // strategy.num_replicas_in_sync
78
79 if 'batch_input_shape' in kwargs:
80 batch_input_shape = kwargs.pop('batch_input_shape')
81 if input_shape and batch_input_shape:
82 raise ValueError('Only provide the input_shape OR '
83 'batch_input_shape argument to '
84 'InputLayer, not both at the same time.')
85 batch_size = batch_input_shape[0]
86 input_shape = batch_input_shape[1:]
87 if kwargs:
88 raise ValueError('Unrecognized keyword arguments:', kwargs.keys())
89
90 if not name:

Callers 1

InputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected