def test_layers_sequential_from_config(): """Test from_config on sequential""" config = { "type": "deepr.layers.Sequential", "*": [{"type": "deepr.layers.Dense", "units": 10}, {"type": "deepr.layers.Identity"}], } sequential = dpr.from_config(config) assert [type(layer) for layer in sequential.layers] == [dpr.layers.Dense, dpr.layers.Identity]
def test_example_multiply_configs(tmpdir): """Test for examples.multiply.configs""" path_model = str(tmpdir.join("model")) path_dataset = str(tmpdir.join("dataset")) config = dpr.io.read_json(PATH_CONFIG / "config.json") macros = dpr.io.read_json(PATH_CONFIG / "macros.json") macros["paths"]["path_model"] = path_model macros["paths"]["path_dataset"] = path_dataset parsed = dpr.parse_config(config, macros) job = dpr.from_config(parsed) job.run()
def test_layers_dag_from_config(): """Test from_config on dag""" config = { "type": "deepr.layers.DAG", "*": [{ "type": "deepr.layers.Dense", "units": 10 }, { "type": "deepr.layers.Identity" }], } dag = deepr.from_config(config) assert [type(layer) for layer in dag.layers ] == [deepr.layers.Dense, deepr.layers.Identity]
def test_prepros_serial_from_config(): """Test from_config on Serial""" config = { "type": "deepr.prepros.Serial", "*": [{ "type": "deepr.prepros.Repeat", "count": 1 }, { "type": "deepr.prepros.Batch", "batch_size": 32 }], } serial = deepr.from_config(config) assert [type(prepro) for prepro in serial.preprocessors ] == [deepr.prepros.Repeat, deepr.prepros.Batch]
def test_example_configs(): """Test for example.configs""" config = dpr.io.read_json(PATH_CONFIG / "config.json") macros = dpr.io.read_json(PATH_CONFIG / "macros.json") parsed = dpr.parse_config(config, macros) dpr.from_config(parsed)
def test_config_from_config(item, expected): assert dpr.from_config(item) == expected
def test_config_from_config_constructor(item, kwargs, expected): constructor = dpr.from_config(item) instance = constructor(**kwargs) assert instance == expected