ValueError: 'penguin classifier/' is not a valid root scope name


I am trying to use penguin dataset just like tutorial.

One change I’ve made is the training, instead of custom training I’ve built model using functional api and compiled it for training. Here is the code:

inputs = tf.keras.Input(shape=(4,))
dense = tf.keras.layers.Dense(10, activation='relu')(inputs)
dense = tf.keras.layers.Dense(10, activation='relu')(dense)
outputs = tf.keras.layers.Dense(3)(dense)

model = tf.keras.Model(inputs=inputs, outputs=outputs, name="penguin classifier")
metrics = [tf.keras.metrics.SparseCategoricalAccuracy()]
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
optimizer = tf.keras.optimizers.SGD(learning_rate=0.01)


Now when I try to fit the model it outputs following error

ValueError: 'penguin classifier/' is not a valid root scope name. A root scope name has to match the following pattern: ^[A-Za-z0-9.][A-Za-z0-9_.\\/>-]*$

When I train using custom training loops that is, using gradientTape it works fine. What is the reason for this?


Valid scope name should match with the following regular expression:


Please use any of these in the name like below instead of space : _ – . > /

model = tf.keras.Model(inputs=inputs, outputs=outputs, name="penguin.classifier")

Answered By – Tfer3

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published