Ejemplo n.º 1
0
 def test_get_individual_size(self, ctrnn_config):
     in_space = Box(-1, 1, shape=[3])
     out_space = Box(-1, 1, shape=[3])
     ContinuousTimeRNN.generate_and_set_class_state(config=ctrnn_config, input_space=in_space,
                                                    output_space=out_space, )
     ind_size = ContinuousTimeRNN.get_individual_size(config=ctrnn_config, input_space=in_space,
                                                      output_space=out_space, )
     assert ind_size == 22
Ejemplo n.º 2
0
 def test_get_individual_size(self, ctrnn_config):
     in_space = Box(-1, 1, shape=[3])
     out_space = Box(-1, 1, shape=[3])
     ContinuousTimeRNN.set_masks_globally(
         config=ctrnn_config,
         input_space=in_space,
         output_space=out_space,
     )
     ind_size = ContinuousTimeRNN.get_individual_size(
         config=ctrnn_config,
         input_space=in_space,
         output_space=out_space,
     )
     assert ind_size == 22
Ejemplo n.º 3
0
    def __init__(self, input_space: Space, output_space: Space,
                 individual: np.ndarray, config: CnnCtrnnCfg):
        super().__init__(input_space, output_space, individual, config)

        assert len(individual) == self.get_individual_size(
            config, input_space, output_space)
        paramter_usage_dict = self.get_free_parameter_usage(
            config, input_space, output_space)
        cnn_output_space = paramter_usage_dict[self._usage_key_cnn_output]
        cnn_size = Cnn.get_individual_size(config.cnn_conf, input_space,
                                           cnn_output_space)
        ctrnn_size = ContinuousTimeRNN.get_individual_size(
            config.ctrnn_conf, cnn_output_space, output_space)
        ind_cnn = individual[0:cnn_size]
        ind_ctrnn = individual[cnn_size:cnn_size + ctrnn_size]
        self.cnn = Cnn(input_space=input_space,
                       output_space=cnn_output_space,
                       config=config.cnn_conf,
                       individual=ind_cnn)
        self.ctrnn = ContinuousTimeRNN(input_space=cnn_output_space,
                                       output_space=output_space,
                                       config=config.ctrnn_conf,
                                       individual=ind_ctrnn)