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

Method __init__

tensorflow/python/keras/engine/input_layer.py:61–149  ·  view source on GitHub ↗
(self,
               input_shape=None,
               batch_size=None,
               dtype=None,
               input_tensor=None,
               sparse=False,
               name=None,
               ragged=False,
               **kwargs)

Source from the content-addressed store, hash-verified

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:
91 prefix = 'input'
92 name = prefix + '_' + str(backend.get_uid(prefix))
93
94 if not dtype:
95 if input_tensor is None:
96 dtype = backend.floatx()
97 else:
98 dtype = backend.dtype(input_tensor)
99 elif input_tensor is not None and input_tensor.dtype != dtype:
100 raise ValueError('`input_tensor.dtype` differs from `dtype`: %s vs. %s' %
101 (input_tensor.dtype, dtype))
102 super(InputLayer, self).__init__(dtype=dtype, name=name)
103 self.built = True
104 self.sparse = sparse
105 self.ragged = ragged
106 self.batch_size = batch_size
107 self.supports_masking = True
108
109 if isinstance(input_shape, tensor_shape.TensorShape):
110 input_shape = tuple(input_shape.as_list())
111 elif isinstance(input_shape, int):
112 input_shape = (input_shape,)
113
114 if input_tensor is None:
115 if input_shape is not None:
116 batch_input_shape = (batch_size,) + tuple(input_shape)
117 else:
118 batch_input_shape = None

Callers

nothing calls this directly

Calls 9

tupleFunction · 0.85
formatMethod · 0.45
popMethod · 0.45
keysMethod · 0.45
dtypeMethod · 0.45
as_listMethod · 0.45
as_defaultMethod · 0.45
placeholderMethod · 0.45
NodeMethod · 0.45

Tested by

no test coverage detected