Пример #1
0
def test_image_block():
    block = wrapper.ImageBlock(normalize=None, augment=None)
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.ImageInput(shape=(32, 32, 3)).build())

    assert utils.name_in_hps('block_type', hp)
    assert utils.name_in_hps('normalize', hp)
    assert utils.name_in_hps('augment', hp)
Пример #2
0
def test_dense_block():
    input_shape = (32,)
    block = basic.DenseBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('num_layers', hp)
    assert utils.name_in_hps('use_batchnorm', hp)
Пример #3
0
def test_embedding_block():
    input_shape = (32,)
    block = basic.Embedding()
    block.max_features = 100
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('pretraining', hp)
    assert utils.name_in_hps('embedding_dim', hp)
Пример #4
0
def test_rnn_block():
    input_shape = (32, 10)
    block = basic.RNNBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('bidirectional', hp)
    assert utils.name_in_hps('layer_type', hp)
    assert utils.name_in_hps('num_layers', hp)
Пример #5
0
def test_conv_block():
    input_shape = (32, 32, 3)
    block = basic.ConvBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('kernel_size', hp)
    assert utils.name_in_hps('num_blocks', hp)
    assert utils.name_in_hps('separable', hp)
Пример #6
0
def test_imag_augmentation():
    input_shape = (32, 32, 3)
    block = preprocessing.ImageAugmentation()
    hp = kerastuner.HyperParameters()

    block = graph_module.deserialize(graph_module.serialize(block))
    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('vertical_flip', hp)
    assert utils.name_in_hps('horizontal_flip', hp)
Пример #7
0
def test_resnet_block(init, build):
    input_shape = (32, 32, 3)
    block = basic.ResNetBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('version', hp)
    assert utils.name_in_hps('pooling', hp)
    assert init.called
    assert build.called
Пример #8
0
def test_xception_block(init, build):
    input_shape = (32, 32, 3)
    block = basic.XceptionBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('activation', hp)
    assert utils.name_in_hps('initial_strides', hp)
    assert utils.name_in_hps('num_residual_blocks', hp)
    assert utils.name_in_hps('pooling', hp)
    assert init.called
    assert build.called
Пример #9
0
def test_text_block():
    block = wrapper.TextBlock()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.TextInput(shape=(1, )).build())

    assert utils.name_in_hps('vectorizer', hp)
Пример #10
0
def test_spatial_reduction():
    input_shape = (32, 32, 3)
    block = reduction.SpatialReduction()
    hp = kerastuner.HyperParameters()

    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('reduction_type', hp)
Пример #11
0
def test_temporal_reduction():
    input_shape = (32, 10)
    block = reduction.TemporalReduction()
    hp = kerastuner.HyperParameters()

    block = graph_module.deserialize(graph_module.serialize(block))
    block.build(hp, ak.Input(shape=input_shape).build())

    assert utils.name_in_hps('reduction_type', hp)
Пример #12
0
def test_merge():
    input_shape_1 = (32, )
    input_shape_2 = (4, 8)
    block = reduction.Merge()
    hp = kerastuner.HyperParameters()

    block.build(hp, [
        ak.Input(shape=input_shape_1).build(),
        ak.Input(shape=input_shape_2).build()
    ])

    assert utils.name_in_hps('merge_type', hp)