1
1
from _typeshed import Incomplete
2
- from collections .abc import Callable , Iterable , Sequence
3
- from typing import Any , Generic , TypeVar , overload
2
+ from collections .abc import Callable , Iterable , Mapping , Sequence
3
+ from typing import Any , Generic , Literal , TypeVar , overload
4
4
from typing_extensions import Self , TypeAlias
5
5
6
6
import tensorflow as tf
7
7
from tensorflow import Tensor , Variable , VariableAggregation , VariableSynchronization
8
- from tensorflow ._aliases import AnyArray , DTypeLike , TensorCompatible
8
+ from tensorflow ._aliases import AnyArray , DTypeLike , TensorCompatible , TensorLike
9
9
from tensorflow .keras .activations import _Activation
10
10
from tensorflow .keras .constraints import Constraint
11
11
from tensorflow .keras .initializers import _Initializer
12
- from tensorflow .keras .regularizers import _Regularizer
12
+ from tensorflow .keras .layers .preprocessing import IntegerLookup as IntegerLookup , StringLookup as StringLookup
10000
13
+ from tensorflow .keras .regularizers import Regularizer , _Regularizer
14
+ from tensorflow .python .feature_column .feature_column_v2 import DenseColumn , SequenceDenseColumn
13
15
14
16
_InputT = TypeVar ("_InputT" , contravariant = True )
15
17
_OutputT = TypeVar ("_OutputT" , covariant = True )
@@ -127,7 +129,7 @@ class Dense(Layer[tf.Tensor, tf.Tensor]):
127
129
kernel_constraint : _Constraint = None ,
128
130
bias_constraint : _Constraint = None ,
129
131
trainable : bool = True ,
130
- dtype : _LayerDtype = None ,
132
+ dtype : _LayerDtype | None = None ,
131
133
dynamic : bool = False ,
132
134
name : str | None = None ,
133
135
) -> None : ...
@@ -149,7 +151,7 @@ class BatchNormalization(Layer[tf.Tensor, tf.Tensor]):
149
151
beta_constraint : _Constraint = None ,
150
152
gamma_constraint : _Constraint = None ,
151
153
trainable : bool = True ,
152
- dtype : _LayerDtype = None ,
154
+ dtype : _LayerDtype | None = None ,
153
155
dynamic : bool = False ,
154
156
name : str | None = None ,
155
157
) -> None : ...
@@ -161,7 +163,7 @@ class ReLU(Layer[tf.Tensor, tf.Tensor]):
161
163
negative_slope : float | None = 0.0 ,
162
164
threshold : float | None = 0.0 ,
163
165
trainable : bool = True ,
164
- dtype : _LayerDtype = None ,
166
+ dtype : _LayerDtype | None = None ,
165
167
dynamic : bool = False ,
166
168
name : str | None = None ,
167
169
) -> None : ...
@@ -173,7 +175,7 @@ class Dropout(Layer[tf.Tensor, tf.Tensor]):
173
175
noise_shape : TensorCompatible | Sequence [int | None ] | None = None ,
174
176
seed : int | None = None ,
175
177
trainable : bool = True ,
176
- dtype : _LayerDtype = None ,
178
+ dtype : _LayerDtype | None = None ,
177
179
dynamic : bool = False ,
178
180
name : str | None = None ,
179
181
) -> None : ...
@@ -189,6 +191,133 @@ class Embedding(Layer[tf.Tensor, tf.Tensor]):
189
191
mask_zero : bool = False ,
190
192
input_length : int | None = None ,
191
193
trainable : bool = True ,
194
+ dtype : _LayerDtype | None = None ,
195
+ dynamic : bool = False ,
196
+ name : str | None = None ,
197
+ ) -> None : ...
198
+
199
+ class Conv2D (Layer [tf .Tensor , tf .Tensor ]):
200
+ def __init__ (
201
+ self ,
202
+ filters : int ,
203
+ kernel_size : int | Iterable [int ],
204
+ strides : int | Iterable [int ] = (1 , 1 ),
205
+ padding : Literal ["valid" , "same" ] = "valid" ,
206
+ data_format : None | Literal ["channels_last" , "channels_first" ] = None ,
207
+ dilation_rate : int | Iterable [int ] = (1 , 1 ),
208
+ groups : int = 1 ,
209
+ activation : _Activation = None ,
210
+ use_bias : bool = True ,
211
+ kernel_initializer : _Initializer = "glorot_uniform" ,
212
+ bias_initializer : _Initializer = "zeros" ,
213
+ kernel_regularizer : _Regularizer = None ,
214
+ bias_regularizer : _Regularizer = None ,
215
+ activity_regularizer : _Regularizer = None ,
216
+ kernel_constraint : _Constraint = None ,
217
+ bias_constraint : _Constraint = None ,
218
+ trainable : bool = True ,
219
+ dtype : _LayerDtype | None = None ,
220
+ dynamic : bool = False ,
221
+ name : str | None = None ,
222
+ ) -> None : ...
223
+
224
+ class Identity (Layer [tf .Tensor , tf .Tensor ]):
225
+ def __init__ (
226
+ self , trainable : bool = True , dtype : _LayerDtype = None , dynamic : bool = False , name : str | None = None
227
+ ) -> None : ...
228
+
229
+ class LayerNormalization (Layer [tf .Tensor , tf .Tensor ]):
230
+ def __init__ (
231
+ self ,
232
+ axis : int = - 1 ,
233
+ epsilon : float = 0.001 ,
234
+ center : bool = True ,
235
+ scale : bool = True ,
236
+ beta_initializer : _Initializer = "zeros" ,
237
+ gamma_initializer : _Initializer = "ones" ,
238
+ beta_regularizer : _Regularizer = None ,
239
+ gamma_regularizer : _Regularizer = None ,
240
+ beta_constraint : _Constraint = None ,
241
+ gamma_constraint : _Constraint = None ,
242
+ trainable : bool = True ,
243
+ dtype : _LayerDtype | None = None ,
244
+ dynamic : bool = False ,
245
+ name : str | None = None ,
246
+ ) -> None : ...
247
+
248
+ class DenseFeatures (Layer [Mapping [str , TensorLike ], tf .Tensor ]):
249
+ def __init__ (
250
+ self ,
251
+ feature_columns : Sequence [DenseColumn | SequenceDenseColumn ],
252
+ trainable : bool = True ,
253
+ dtype : _LayerDtype = None ,
254
+ dynamic : bool = False ,
255
+ name : str | None = None ,
256
+ ) -> None : ...
257
+
258
+ class MultiHeadAttention (Layer [Any , tf .Tensor ]):
259
+ def __init__ (
260
+ self ,
261
+ num_heads : int ,
262
+ key_dim : int | None ,
263
+ value_dim : int | None = None ,
264
+ dropout : float = 0.0 ,
265
+ use_bias : bool = True ,
266
+ output_shape : tuple [int , ...] | None = None ,
267
+ attention_axes : tuple [int , ...] | None = None ,
268
+ kernel_initialize : _Initializer = "glorot_uniform" ,
269
+ bias_initializer : _Initializer = "zeros" ,
270
+ kernel_regularizer : Regularizer | None = None ,
271
+ bias_regularizer : _Regularizer | None = None ,
272
+ activity_regularizer : _Regularizer | None = None ,
273
+ kernel_constraint : _Constraint | None = None ,
274
+ bias_constraint : _Constraint | None = None ,
275
+ trainable : bool = True ,
276
+ dtype : _LayerDtype | None = None ,
277
+ dynamic : bool = False ,
278
+ name : str | None = None ,
279
+ ) -> None : ...
280
+ # @override
281
+ @overload # type: ignore
282
+ def __call__ (
283
+ self ,
284
+ query : tf .Tensor ,
285
+ value : tf .Tensor ,
286
+ key : tf .Tensor | None ,
287
+ attention_mask : tf .Tensor | None ,
288
+ return_attention_scores : Literal [False ],
289
+ training : bool ,
290
+ use_causal_mask : bool ,
291
+ ) -> tf .Tensor : ...
292
+ @overload
293
+ def __call__ (
294
+ self ,
295
+ query : tf .Tensor ,
296
+ value : tf .Tensor ,
297
+ key : tf .Tensor | None ,
298
+ attention_mask : tf .Tensor | None ,
299
+ return_attention_scores : Literal [True ],
300
+ training : bool ,
301
+ use_causal_mask : bool ,
302
+ ) -> tuple [tf .Tensor , tf .Tensor ]: ...
303
+ @overload
304
+ def __call__ (
305
+ self ,
306
+ query : tf .Tensor ,
307
+ value : tf .Tensor ,
308
+ key : tf .Tensor | None = None ,
309
+ attention_mask : tf .Tensor | None = None ,
310
+ return_attention_scores : bool = False ,
311
+ training : bool = False ,
312
+ use_causal_mask : bool = False ,
313
+ ) -> tuple [tf .Tensor , tf .Tensor ] | tf .Tensor : ...
314
+
315
+ class GaussianDropout (Layer [tf .Tensor , tf .Tensor ]):
316
+ def __init__ (
317
+ self ,
318
+ rate : float ,
319
+ seed : int | None = None ,
320
+ trainable : bool = True ,
192
321
dtype : _LayerDtype = None ,
193
322
dynamic : bool = False ,
194
323
name : str | None = None ,
0 commit comments