in models.py [0:0]
def create_full_model(self, layer_to_explore, layer_to_explore_size, image_size):
all_layers = dict(list(self.pretrained_model.named_children()))
all_keys = list(
all_layers.keys()
) # TODO: I am not sure the order is preserved ?
max_index = all_keys.index(layer_to_explore)
##### ENCODER
# take all layers up to the one we want to explore for the encoder
encoder_layers = [
(all_keys[i], all_layers[layer])
for i, layer in enumerate(all_layers)
if i <= max_index
]
layers = OrderedDict()
for layer in encoder_layers:
name = layer[0]
layers[name] = layer[1]
# create a new model with it (saves time during feed-forward if we take other layers than the last one)
self.fixed_encoder = nn.Sequential(layers)
##### Linear layer to learn the mapping
self.linear = nn.Linear(layer_to_explore_size, layer_to_explore_size)
##### DECODER
self.decoder = nn.Linear(layer_to_explore_size, image_size)