TensorFlow2.0-Examples icon indicating copy to clipboard operation
TensorFlow2.0-Examples copied to clipboard

Problem about ResNet.

Open A-cunminF opened this issue 3 years ago • 0 comments

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.

A-cunminF avatar Dec 03 '21 09:12 A-cunminF