Run forward from specific layer

Hi Everyone,
I’m using a pretrained Resnet18 model, my main challenge is to run a feature vector that i already have
(taken from another model last avgpool layer) and finish the run with the help of the last fc layer and detect all objects that this feature vector represent.

some code

np_fv = np.load('feature_vector.npy')
fv = torch.from_numpy(np_fv)
fv.shape #torch.Size([512])

# Load the pretrained model
model = models.resnet18(pretrained=True)

# Use the model object to select the desired layer
layer = model._modules.get('fc')

# Set model to evaluation mode

#imageNet has 1k classes so fc output dim is 1k
my_embedding = torch.zeros(1000)
def copy_data(m, i, o):
h = layer.register_forward_hook(copy_data)

model.avgpool =  # what should I do next?

how do i get prediction only from feature_vector without the input image?

If you only want to use the fc layer of the pretrained resnet, you could use it as:

fv = ...
output = model.fc(fv)

I’m not sure, if I misunderstand the question or why you need forward hooks.