faustomorales / vit-keras

Keras implementation of ViT (Vision Transformer)
Apache License 2.0
329 stars 78 forks source link

Layer names mismatch #3

Closed faustomorales closed 3 years ago

faustomorales commented 3 years ago

As of TF 2.4.0, loading a pretrained model from the numpy weights results in AssertionError: Transformer/encoderblock_0/MlpBlock_3/Dense_0/kernel:0 not in output weights..

This is because of a breaking change in TF 2.4.0 that makes it so we can no longer rely on the same weights namespacing at the top level of a model. From the release notes.

Code that is overly dependent on the exact names attached to symbolic tensors (e.g. assumes there will be ":0" at the end of the inputs, treats names as unique identifiers instead of using tensor.ref(), etc.) may break.

I probably shouldn't have relied so heavily on the naming the first place, but this will require significant changes to vit_keras.utils.load_weights_numpy.

faustomorales commented 3 years ago

Fixed in c39b5b1bd4be455ae3f2e291822d91a4fa703439