@keras_test
def test_masking_layer():
 I = np.random.random((6, 3, 4))
 V = np.abs(np.random.random((6, 3, 5)))
 V /= V.sum(axis=(-1), keepdims=True)
 model = Sequential()
 model.add(Masking(input_shape=(3, 4)))
 model.add(recurrent.LSTM(output_dim=5, return_sequences=True, unroll=False))
 model.compile(loss='categorical_crossentropy', optimizer='adam')
 model.fit(I, V, nb_epoch=1, batch_size=100, verbose=1)
 model = Sequential()
 model.add(Masking(input_shape=(3, 4)))
 model.add(recurrent.LSTM(output_dim=5, return_sequences=True, unroll=True))
 model.compile(loss='categorical_crossentropy', optimizer='adam')
 model.fit(I, V, nb_epoch=1, batch_size=100, verbose=1)

@ keras_test def test_masking_layer ( ) : I = np . random . random ( ( 6 , 3 , 4 ) ) V = np . abs ( np . random . random ( ( 6 , 3 , 5 ) ) ) V /= V . sum ( axis = ( - 1 ) , keepdims = True ) model = Sequential ( ) model . add ( Masking ( input_shape = ( 3 , 4 ) ) ) model . add ( recurrent . LSTM ( output_dim = 5 , return_sequences = True , unroll = False ) ) model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adam' ) model . fit ( I , V , nb_epoch = 1 , batch_size = 100 , verbose = 1 ) model = Sequential ( ) model . add ( Masking ( input_shape = ( 3 , 4 ) ) ) model . add ( recurrent . LSTM ( output_dim = 5 , return_sequences = True , unroll = True ) ) model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adam' ) model . fit ( I , V , nb_epoch = 1 , batch_size = 100 , verbose = 1 )
this test based on a previously failing issue here: URL .