faustomorales / vit-keras

Keras implementation of ViT (Vision Transformer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The [call] method in TransformerBlock has different input args

knaffe opened this issue · comments

I see the call method in TransformerBlock has 2 input:
def call(self, inputs, training)
But when the script call TransformerBlock in vit.py, it is :

for n in range(num_layers): 
        y, _ = layers.TransformerBlock( 
            num_heads=num_heads, 
            mlp_dim=mlp_dim, 
            dropout=dropout, 
            name=f"Transformer/encoderblock_{n}", 
        )(y) 

Does is work in this way?
May I miss something in this repo?
Thanks a lot.

The call method is not called directly in the snippet you included above. call is part of the Keras API, which requires you to implement the __init__, build, and call methods. The snippet above executes the __init__ (implemented by us) and __call__ (implemented by Keras) methods. Keras will use the call method under-the-hood.

Closing as this is not a bug. Please use StackOverflow for Q&A about the TensorFlow Keras API.