Base on code Genetic CNN by TORCH and add the def update_stages_state in Stages to change curent CNN state architecture of Individual
class Stages(torch.nn.Module):
...
def update_stages_state(self, new_gen):
if type(new_gen) != tuple:
raise ValueError("new gen must be tuple")
for i in range(len(new_gen)):
self.stages[i].binary_code = new_gen[i]
self.stages[i].inputs, self.stages[i].outputs, self.stages[i].separated_connections = Stage.get_nodes_connections(self.num_stages[i], new_gen[i])
self.gen = self.get_gen()
self.gen_model = self.get_gen('model')
...
Change architecture of connection to reduce time of Genetic Algorithm, it only train the necessary architecture if the different of base model to approximately model not large
file log.csv and model.pt is log about training model {'S_1': '1-11', 'S_2': '1-11-111-1111'} and change architecture to some different architecture
- The different of base model to approximately model mean the connection between nodes in Stage and the contribution of the node if exist or not
- Each Stage have effect to the final model follow Conditional probability
- In some case the weight of the base model is suitable to approximately model more than base model (acc better, loss lesser)
If want to test the new model, delete file log.csv and model.pt
- pytorch >= 1.9