Skip to content

Commit c2a7c69

Browse files
committed
Update doc re: layer reconstruction
1 parent 4cd3d28 commit c2a7c69

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/templates/layers/about-keras-layers.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ All Keras layers have a number of methods in common:
55
- `layer.get_weights()`: returns the weights of the layer as a list of Numpy arrays.
66
- `layer.set_weights(weights)`: sets the weights of the layer from a list of Numpy arrays (with the same shapes as the output of `get_weights`).
77
- `layer.get_config()`: returns a dictionary containing the configuration of the layer. The layer can be reinstantiated from its config via:
8+
9+
```python
10+
layer = Dense(32)
11+
config = layer.get_config()
12+
reconstructed_layer = Dense.from_config(config)
13+
```
14+
15+
Or:
16+
817
```python
918
from keras.utils.layer_utils import layer_from_config
1019

1120
config = layer.get_config()
12-
layer = layer_from_config(config)
21+
layer = layer_from_config({'class_name': layer.__class__.__name__,
22+
'config': config})
1323
```
1424

1525
If a layer has a single node (i.e. if it isn't a shared layer), you can get its input tensor, output tensor, input shape and output shape via:

0 commit comments

Comments
 (0)