Error when running eval_cifar10.py
Hello. I have trained the network but when running the eval_cifar10.py file, i get the following error. Why this might be happening?
Traceback (most recent call last):
File "/data22/nas/NN_calibration/scripts/resnet_cifar/eval_model_c10.py", line 130, in
Dimensions must be equal, but are 10 and 64 for '{{node dense/MatMul}} = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false](Placeholder, dense/MatMul/ReadVariableOp)' with input shapes: [?,10], [64,10].
Call arguments received by layer "dense" (type Dense): • inputs=tf.Tensor(shape=(None, 10), dtype=float32)
Hey!
This is quite old code. Thus, it uses an older version of Keras (likely Keras 2.3.1), and other packages could influence the behaviour.
The problem is that lines 30-34 in "utility/evaluate.py", where the last layers activation is changed to linear to get logits, do not work properly for newer Keras versions.
Let me know if you have more questions.
All the best, Markus
Hey!
This is quite old code. Thus, it uses an older version of Keras (likely Keras 2.3.1), and other packages could influence the behaviour.
The problem is that lines 30-34 in "utility/evaluate.py", where the last layers activation is changed to linear to get logits, do not work properly for newer Keras versions.
Let me know if you have more questions.
All the best, Markus
Thanks Markus. So what could be the way forward? How do we do this in the newer version of keras?
You could try model._layers.pop() instead of model.layers.pop(), maybe that does the trick. Or some other workaround from here https://stackoverflow.com/questions/57316557/tf-keras-layers-pop-doesnt-work-but-tf-keras-layers-pop-does.