faustomorales / vit-keras

Keras implementation of ViT (Vision Transformer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Layer names mismatch

faustomorales opened this issue · comments

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.