Example #1
0
def test_output_dims():
    data = Array('testa', numpy.zeros((10, 10, 1)))
    label = Array('testy', numpy.zeros((10, 1)))
    xin = Input(data.shape, name='asdf')
    out = Flatten()(xin)
    out = Dense(1)(out)
    m = Model(xin, out)

    # False due to mismatch of names
    assert not _dimension_match(m, label, 'output_layers')

    xin = Input(data.shape, name='testa')
    out = Flatten()(xin)
    out = Dense(2, name='testy')(out)
    m = Model(xin, out)

    # False due to mismatch of dims
    assert not _dimension_match(m, label, 'output_layers')

    xin = Input(data.shape, name='testa')
    out = Flatten()(xin)
    out = Dense(1, name='testy')(out)
    m = Model(xin, out)

    # False due to mismatch of dims
    assert _dimension_match(m, label, 'output_layers')

    assert _dimension_match(m, None, 'output_layers')
Example #2
0
def test_input_dims():
    data = Array('testa', numpy.zeros((10, 10, 1)))
    xin = Input((10, 1), name='testy')
    out = Dense(1)(xin)
    m = Model(xin, out)

    # False due to mismatch of names
    assert not _dimension_match(m, data, 'input_layers')

    xin = Input((20, 10, 1), name='testa')
    out = Dense(1)(xin)
    m = Model(xin, out)

    # False due to mismatch of dims
    assert not _dimension_match(m, data, 'input_layers')
    # more input datasets supplied than inputs to models
    assert not _dimension_match(m, [data, data], 'input_layers')

    xin = Input((10, 1), name='testa')
    out = Dense(1)(xin)
    m = Model(xin, out)

    # False due to mismatch of dims
    assert _dimension_match(m, data, 'input_layers')