Tutorial: control the size of a network#

Select a model from a checkpoint#

We can also control the size of the network, by selecting any model from the checkpoint file of a built model, and restart the build from that stage. We can choose to enrich the model by adding some trainable parameters, or not (meaning that the weights will be optimized but without adding trainable parameters). In this case, there are 3 building parameters to use:

  • checkpoint_to_start_build_from

  • start_build_from_model_number

  • freeze_structure

For example, using the regular network built above we can choose the checkpoint n°5, and restart the build from that point.

new_model = Tabular.Regressor()
index_of_model_to_improve = 4

new_model.build(input_data=x_train, output_data=y_train,
                # the rest of these parameters are optional
                checkpoint_to_start_build_from="./MetamaterialsAntennas/MetamaterialsAntennas.checkpoint",
                start_build_from_model_number=index_of_model_to_improve,
                freeze_structure=True,
                write_model_to = "./MetamaterialsAntennas/MetamaterialsAntennas_improved",
                checkpoint_address = "./MetamaterialsAntennas/MetamaterialsAntennas_improved.checkpoint",
                valid_percentage = 33.33,
                outputs_normalize_per_feature = True)

print("Imroved Model n° of trainable parameters: {0}".format(new_model.vec.size))
new_model.plot_network()

The new model will have the following architecture:

MbedNetworkFromCkpt

Controlling the size of a network by restarting the build from a checkpoint#