@keras_test
def test_temporal_classification():
 ((X_train, y_train), (X_test, y_test)) = get_test_data(nb_train=500, nb_test=500, input_shape=(3, 5), classification=True, nb_class=2)
 y_train = to_categorical(y_train)
 y_test = to_categorical(y_test)
 model = Sequential()
 model.add(GRU(y_train.shape[(-1)], input_shape=(X_train.shape[1], X_train.shape[2]), activation='softmax'))
 model.compile(loss='categorical_crossentropy', optimizer='adagrad', metrics=['accuracy'])
 history = model.fit(X_train, y_train, nb_epoch=20, batch_size=32, validation_data=(X_test, y_test), verbose=0)
 assert (history.history['val_acc'][(-1)] >= 0.8)

@ keras_test def test_temporal_classification ( ) : ( ( X_train , y_train ) , ( X_test , y_test ) ) = get_test_data ( nb_train = 500 , nb_test = 500 , input_shape = ( 3 , 5 ) , classification = True , nb_class = 2 ) y_train = to_categorical ( y_train ) y_test = to_categorical ( y_test ) model = Sequential ( ) model . add ( GRU ( y_train . shape [ ( - 1 ) ] , input_shape = ( X_train . shape [ 1 ] , X_train . shape [ 2 ] ) , activation = 'softmax' ) ) model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adagrad' , metrics = [ 'accuracy' ] ) history = model . fit ( X_train , y_train , nb_epoch = 20 , batch_size = 32 , validation_data = ( X_test , y_test ) , verbose = 0 ) assert ( history . history [ 'val_acc' ] [ ( - 1 ) ] >= 0.8 )
classify temporal sequences of float numbers of length 3 into 2 classes using single layer of gru units and softmax applied to the last activations of the units .