Useful functions for scenarios

  • create_subscenario(base_scenario, task_indexes)

This function makes it possible to slice a scenario by selecting only a subset of tasks or to reorder classes with a new order of task indexes.

  • get_scenario_remapping(scenario)->

This function provided a remapping of class that ensure that labels comes in a continuous increasing order. It is particularly useful if order of tasks has been changed (for example with create_subscenario). This function is often use with the function remap_class_vector which will apply the remapping.

The mapping can also be build online with update_remapping(class_vector, mapping) (it is more rigorous but it is also more computationnaly costly and it does not change the final results).

  • encode_scenario(scenario, model, batch_size, file_name, inference_fct=None)

This function makes it possible to create a scenario with latent representation of a given model. For example, when you have a frozen pretrained model and you want to just train the last layers. With encode_scenario function, you can create a scenario with the data already encoded. This function will save all the latent vectors into a hdf5 files and create the exact same initial scenario with encoded vectors. It reduces the computation footprint and the time spent on encoding data for every experiences.