I have the following code:
import tensorflow as tf
from tensorflow import keras
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense
import logging
# I create my model here:
tf.random.set_seed(1234)
model = tf.keras.models.Sequential(
[
tf.keras.Input(shape=(2,)),
Dense(3, activation='sigmoid', name = 'layer1'),
Dense(1, activation='sigmoid', name = 'layer2')
]
)
model.summary()
Once I run the model summary, I get the following result:
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
module_wrapper (ModuleWrap (None, 3) 9
per)
module_wrapper_1 (ModuleWr (None, 1) 4
apper)
=================================================================
Total params: 13 (52.00 Byte)
Trainable params: 13 (52.00 Byte)
Non-trainable params: 0 (0.00 Byte)
_________________________________________________________________
What I was expecting to get is:
Model: "sequential_1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
layer1 (Dense) (None, 3) 9
layer2 (Dense) (None, 1) 4
=================================================================
Total params: 13
Trainable params: 13
Non-trainable params: 0
_________________________________________________________________
So, it's not saving my layers names for some reason that I don't understand, and its giving weird "module_wrapper_xyz" names instead.
What am I doing wrong with the naming's?
How Is it not assigning the names correctly to each layer?
My dependencies are (if necessary):
tensorflow = {version = "^2.13.0" }
python = ">=3.10,<3.12"
matplotlib = "^3.6.3"
keras = "^2.11.0"
jupyterlab = "^3.5.3"
scikit-learn = "^1.2.1"
numpy = "^1.26.0"
jupyter = "^1.0.0"
xdurch0 is right. Just import without .python
as bellow and you will get the correct layer names.
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense