YunYang1994 / TensorFlow2.0-Examples

🙄 Difficult algorithm, Simple code.
MIT License
1.71k stars 674 forks source link

Problem about ResNet. #134

Open A-cunminF opened 3 years ago

A-cunminF commented 3 years ago

Meet a problem when applying model by compile-build-fit route.

In 'resent.py' ,row 112: out = tf.reshape(out, (out.shape[0], -1))

By using out.shape, it will return a tuple rather than a tensor, which will be a problem when training the model by the 'model.fit' method. Although it can be fine when setting run_fucntions_eagerly as True or just using Gradient Tape as in the 'main.py', it will cause unnecessary extra time when training.

It can be fixed when using Keras.layers.Faltten() or out = tf.reshape(out, (tf.shape(out)[0], -1)) instead. About 25% faster in my computer.