示例#1
0
 def test_parameters(self):
     experiment_parameters = ExperimentParameters(use_default_values=False)
     for layer in reference_parameters['layers'].keys():
         for name, _value in reference_parameters['layers'][layer].items():
             self.assertIsNotNone(
                 experiment_parameters.get_layer_parameter('%s.%s' % (layer, name)),
                 'Parameter %s should exist for layer %s' % (name, layer))
示例#2
0
    def test_custom_definitions(self):

        def custom_activation(x):
            return x

        register_custom_activation('custom_activation', custom_activation)
        register_custom_layer('Dense2', Dense, dict(test='test'))
        experiment_parameters = ExperimentParameters(use_default_values=False)
        custom_params = experiment_parameters.get_layer_parameter('Dense2')
        self.assertIsNotNone(
            custom_params,
            'Should have registered custom layer')
        self.assertTrue(
            'test' in custom_params,
            'Should have registered custom layer params')
        activations = experiment_parameters.get_layer_parameter('Dense.activation')
        self.assertTrue(
            'custom_activation' in activations.values,
            'Should have registered custom_activation')
示例#3
0
 def test_custom_parameters(self):
     experiment_parameters = ExperimentParameters()
     experiment_parameters.layout_parameter('blocks', int_param(1, 10))
     param = experiment_parameters.get_layout_parameter('blocks')
     self.assertTrue(
         1 == param.lo and 10 == param.hi,
         'Should have set values')
     experiment_parameters.layout_parameter('layers', int_param(1, 3))
     param = experiment_parameters.get_layout_parameter('layers')
     self.assertTrue(
         1 == param.lo and 3 == param.hi,
         'Should have set values')
     experiment_parameters.layer_parameter('Dense.activation', string_param(['relu', 'tanh']))
     param = experiment_parameters.get_layer_parameter('Dense.activation')
     self.assertTrue(
         'relu' == param.values[0] and 'tanh' == param.values[1],
         'Should have set values')