def test_PredictionLayer(activation, use_bias): with CustomObjectScope({'PredictionLayer': layers.PredictionLayer}): layer_test(layers.PredictionLayer, kwargs={ 'activation': activation, 'use_bias': use_bias }, input_shape=(BATCH_SIZE, 1))
def test_MLP(hidden_size, use_bn): with CustomObjectScope({'MLP': layers.MLP}): layer_test(layers.MLP, kwargs={ 'hidden_size': hidden_size, 'use_bn': use_bn }, input_shape=(BATCH_SIZE, EMBEDDING_SIZE))
def test_CrossNet_invalid(): with pytest.raises(ValueError): with CustomObjectScope({'CrossNet': layers.CrossNet}): layer_test(layers.CrossNet, kwargs={ 'layer_num': 1, 'l2_reg': 0 }, input_shape=(2, 3, 4))
def test_SequencePoolingLayer(seq_len_max, mode): with CustomObjectScope( {'SequencePoolingLayer': sequence.SequencePoolingLayer}): layer_test(sequence.SequencePoolingLayer, kwargs={ 'seq_len_max': seq_len_max, 'mode': mode }, input_shape=[(BATCH_SIZE, SEQ_LENGTH, EMBEDDING_SIZE), (BATCH_SIZE, 1)])
def test_AttentionSequencePoolingLayer(weight_normalization): with CustomObjectScope({ 'AttentionSequencePoolingLayer': sequence.AttentionSequencePoolingLayer }): layer_test(sequence.AttentionSequencePoolingLayer, kwargs={'weight_normalization': weight_normalization}, input_shape=[(BATCH_SIZE, 1, EMBEDDING_SIZE), (BATCH_SIZE, SEQ_LENGTH, EMBEDDING_SIZE), (BATCH_SIZE, 1)])
def test_LocalActivationUnit(hidden_size, activation): with CustomObjectScope({'LocalActivationUnit': layers.LocalActivationUnit}): layer_test(layers.LocalActivationUnit, kwargs={ 'hidden_size': hidden_size, 'activation': activation }, input_shape=[(BATCH_SIZE, 1, EMBEDDING_SIZE), (BATCH_SIZE, SEQ_LENGTH, EMBEDDING_SIZE)])
def test_CrossNet( layer_num, l2_reg, ): with CustomObjectScope({'CrossNet': layers.CrossNet}): layer_test(layers.CrossNet, kwargs={ 'layer_num': layer_num, 'l2_reg': l2_reg }, input_shape=(2, 3))
def test_dice(): with CustomObjectScope({'Dice': activations.Dice}): layer_test(activations.Dice, kwargs={}, input_shape=(2, 3))
def test_BiInteractionPooling(): with CustomObjectScope( {'BiInteractionPooling': layers.BiInteractionPooling}): layer_test(layers.BiInteractionPooling, kwargs={}, input_shape=(BATCH_SIZE, FIELD_SIZE, EMBEDDING_SIZE))
def test_OutterProductLayer(kernel_type): with CustomObjectScope({'OutterProductLayer': layers.OutterProductLayer}): layer_test(layers.OutterProductLayer, kwargs={'kernel_type': kernel_type}, input_shape=[(BATCH_SIZE, 1, EMBEDDING_SIZE)] * FIELD_SIZE)
def test_InnerProductLayer(reduce_sum): with CustomObjectScope({'InnerProductLayer': layers.InnerProductLayer}): layer_test(layers.InnerProductLayer, kwargs={'reduce_sum': reduce_sum}, input_shape=[(BATCH_SIZE, 1, EMBEDDING_SIZE)] * FIELD_SIZE)
def test_AFMLayer(): with CustomObjectScope({'AFMLayer': layers.AFMLayer}): layer_test(layers.AFMLayer, kwargs={}, input_shape=[(BATCH_SIZE, 1, EMBEDDING_SIZE)] * FIELD_SIZE)
def test_FM(): with CustomObjectScope({'FM': layers.FM}): layer_test(layers.FM, kwargs={}, input_shape=(BATCH_SIZE, FIELD_SIZE, EMBEDDING_SIZE))
def test_test_PredictionLayer_invalid(): # with pytest.raises(ValueError): with CustomObjectScope({'PredictionLayer': layers.PredictionLayer}): layer_test(layers.PredictionLayer, kwargs={'use_bias': use_bias}, input_shape=(BATCH_SIZE, 2, 1))