Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Anyone familiar with tensorflow? 

Here's my code : 

```
try:
            model: object = tf.keras.Sequential([
                base_model,
                tf.keras.layers.Conv2D(32, 3, activation='relu'),
                tf.keras.layers.Dropout(0.2),
                tf.keras.layers.GlobalAveragePooling2D(),
                tf.keras.layers.Dense(36, activation='softmax')
            ])

            tf.compat.v1.enable_eager_execution()

            model.compile(
                optimizer=tf.keras.optimizers.Adam(
                    learning_rate=0.001,
                    beta_1=0.9,
                    beta_2=0.999,
                    epsilon=1e-07,
                    amsgrad=False,
                    name='Adam'
                ),
                loss='categorical_crossentropy',
                metrics=["accuracy"]
            )

            model.fit(
                train_generator,
                epochs=self.epochs,
                validation_data=value_generator,
                validation_steps=10,
                verbose=1
            )
        except Exception as e:
            print(str(e))
 ```

The error I got:

```
Graph execution error:

Detected at node 'categorical_crossentropy/softmax_cross_entropy_with_logits' defined at (most recent call last):
...
 return tf.nn.softmax_cross_entropy_with_logits(
Node: 'categorical_crossentropy/softmax_cross_entropy_with_logits'
logits and labels must be broadcastable: logits_size=[13,36] labels_size=[13,21]
         [[{{node categorical_crossentropy/softmax_cross_entropy_with_logits}}]] 

```
Has anyone encountered this before?


What I have tried:

I tried `Model.fit(x='', y='', epochs=1) ` still doesn't work
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900