How can we load the checkpoint from movinet to fine tune? #13549
Unanswered
thuanbui1309
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am trying to fine tuning the pre-trained movinet a2 stream model with a subset of ucf101 dataset. Originally the movinet a2 has 600 classes as output, but the subset I want to fine tune on only has 10 classess. I try to load the check points and training from that but it keeps saying mismatch in num classess. Below is my code:
`
model_id = 'a2'
use_positional_encoding = model_id in {'a3', 'a4', 'a5'}
resolution = 224
backbone = movinet.Movinet(
model_id=model_id,
causal=True,
conv_type='2plus1d',
se_type='2plus3d',
activation='hard_swish',
gating_activation='hard_sigmoid',
use_positional_encoding=use_positional_encoding,
use_external_states=False,
)
def build_classifier(batch_size, num_frames, resolution, backbone, num_classes):
"""Builds a classifier on top of a backbone model."""
model = movinet_model.MovinetClassifier(
backbone=backbone,
num_classes=num_classes)
model.build([batch_size, num_frames, resolution, resolution, 3])
return model
Construct loss, optimizer and compile the model
with distribution_strategy.scope():
model = build_classifier(batch_size, num_frames, resolution, backbone, 10)
loss_obj = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
optimizer = tf.keras.optimizers.Adam(learning_rate = 0.001)
model.compile(loss=loss_obj, optimizer="Adam", metrics=['accuracy'])
`
Beta Was this translation helpful? Give feedback.
All reactions