Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14f11c9

Browse files
Mention functional API in the migration docstrings of core.py.
PiperOrigin-RevId: 381059294
1 parent 5e3ff5a commit 14f11c9

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

keras/legacy_tf_layers/core.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Dense(keras_layers.Dense, base.Layer):
9090
9191
Please refer to [tf.layers section of the migration guide]
9292
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
93-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
93+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
9494
layer is `tf.keras.layers.Dense`.
9595
9696
@@ -206,7 +206,7 @@ def dense(
206206
207207
Please refer to [tf.layers section of the migration guide]
208208
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
209-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
209+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
210210
layer is `tf.keras.layers.Dense`.
211211
212212
@@ -222,8 +222,13 @@ def dense(
222222
223223
After:
224224
225+
To migrate code using TF1 functional layers use the [Keras Functional API]
226+
(https://www.tensorflow.org/guide/keras/functional):
227+
225228
```python
229+
x = tf.keras.Input((28,))
226230
y = tf.keras.layers.Dense(units=3)(x)
231+
model = tf.keras.Model(x, y)
227232
```
228233
@end_compatibility
229234
@@ -278,7 +283,7 @@ class Dropout(keras_layers.Dropout, base.Layer):
278283
279284
Please refer to [tf.layers section of the migration guide]
280285
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
281-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
286+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
282287
layer is `tf.keras.layers.Dropout`.
283288
284289
@@ -359,7 +364,7 @@ def dropout(inputs,
359364
360365
Please refer to [tf.layers section of the migration guide]
361366
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
362-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
367+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
363368
layer is `tf.keras.layers.Dropout`.
364369
365370
@@ -375,8 +380,13 @@ def dropout(inputs,
375380
376381
After:
377382
383+
To migrate code using TF1 functional layers use the [Keras Functional API]
384+
(https://www.tensorflow.org/guide/keras/functional):
385+
378386
```python
387+
x = tf.keras.Input((28, 28, 1))
379388
y = tf.keras.layers.Dropout()(x)
389+
model = tf.keras.Model(x, y)
380390
```
381391
@end_compatibility
382392
"""
@@ -416,7 +426,7 @@ class Flatten(keras_layers.Flatten, base.Layer):
416426
417427
Please refer to [tf.layers section of the migration guide]
418428
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
419-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
429+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
420430
layer is `tf.keras.layers.Flatten`.
421431
422432
@@ -474,7 +484,7 @@ def flatten(inputs, name=None, data_format='channels_last'):
474484
475485
Please refer to [tf.layers section of the migration guide]
476486
(https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
477-
for more details on migrating a TF1 model to Keras. In TF2 the corresponding
487+
to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
478488
layer is `tf.keras.layers.Flatten`.
479489
480490
@@ -490,8 +500,13 @@ def flatten(inputs, name=None, data_format='channels_last'):
490500
491501
After:
492502
503+
To migrate code using TF1 functional layers use the [Keras Functional API]
504+
(https://www.tensorflow.org/guide/keras/functional):
505+
493506
```python
507+
x = tf.keras.Input((28, 28, 1))
494508
y = tf.keras.layers.Flatten()(x)
509+
model = tf.keras.Model(x, y)
495510
```
496511
@end_compatibility
497512
"""

0 commit comments

Comments
 (0)