Пример #1
0
 def test_generator_model_config(self):
     config_dict = {
         'bridge': NoOpBridgeConfig().to_schema(),
         'encoder': {
             'input_layers': ['image'],
             'output_layers': ['encoded'],
             'layers': [
                 {'Dense': {'units': 1, 'name': 'encoded'}}
             ]
         },
         'decoder': {
             'input_layers': ['image'],
             'output_layers': ['encoded'],
             'layers': [
                 {'Dense': {'units': 1, 'name': 'decoded'}}
             ]
         },
         'loss': MeanSquaredErrorConfig(input_layer=['image', 0, 0],
                                        output_layer=['decoded', 0, 0]).to_schema(),
         'optimizer': AdamConfig(learning_rate=0.01).to_schema(),
         'metrics': [],
         'summaries': ['loss', 'gradients'],
         'clip_gradients': 0.5,
         'clip_embed_gradients': 0.,
         'name': 'model'}
     config = GeneratorConfig.from_dict(config_dict)
     config_to_dict = config.to_dict()
     assert config_dict.pop('bridge') == config_to_dict.pop('bridge')
     assert_equal_graphs(config_dict.pop('encoder'), config_to_dict.pop('encoder'))
     assert_equal_graphs(config_dict.pop('decoder'), config_to_dict.pop('decoder'))
     assert_equal_dict(config_dict, config_to_dict)
Пример #2
0
 def test_graph_config(self):
     config_dict = {
         'input_layers': ['image'],
         'output_layers': [['dense_0', 0, 0]],
         'layers': [
             {
                 'Conv2D': {
                     'filters': 64,
                     'strides': [1, 1],
                     'kernel_size': [2, 2],
                     'activation': 'relu',
                     'name': 'convolution_1',
                 }
             },
             {'Dense': {'units': 17, 'name': 'dense_0'}}
         ]
     }
     config = GraphConfig.from_dict(config_dict)
     config_to_dict = config.to_dict()
     assert_equal_graphs(config_dict, config_to_dict)
Пример #3
0
 def assert_equal_models(result_model, expected_model):
     assert_equal_graphs(expected_model.pop('graph'), result_model.pop('graph'))
     assert_equal_dict(result_model, expected_model)