I fine-tuned a I3D_ResNetV1 action recognition model implemented with MxNet on a custom dataset, and obtained a model-symbol.json and a model-0000.params files. Now, I can load and use the model by:
model = mx.gluon.nn.SymbolBlock.imports(symbols_file_path, ["data"], parameters_file_path, ctx=context)
However, I don’t want to get the final output of the model, but only the output of the feature extractor. The model's forward method is something like:
def hybrid_forward(self, F, x):
"""Hybrid forward of I3D network"""
x = self.first_stage(x)
outs = []
for i, res_layer in enumerate(self.res_layers):
x = res_layer(x)
if i in self.out_indices:
outs.append(x)
if i == 0:
x = self.pool2(x)
feat = outs[0]
# spatial temporal average
pooled_feat = self.st_avg(feat)
x = F.squeeze(pooled_feat, axis=(2, 3, 4))
# segmental consensus
x = F.reshape(x, shape=(-1, self.num_segments * self.num_crop, self.feat_dim))
x = F.mean(x, axis=1)
if self.feat_ext:
return x
x = self.head(x)
So, basically I'm interested in getting the "feat" quantity. Do you know how can I do this?