@keras_test
def test_vector_classification():
 np.random.seed(1337)
 nb_hidden = 10
 ((X_train, y_train), (X_test, y_test)) = get_test_data(nb_train=500, nb_test=200, input_shape=(20,), classification=True, nb_class=2)
 y_train = to_categorical(y_train)
 y_test = to_categorical(y_test)
 model = Sequential([Dense(nb_hidden, input_shape=(X_train.shape[(-1)],), activation='relu'), Dense(y_train.shape[(-1)], activation='softmax')])
 model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
 history = model.fit(X_train, y_train, nb_epoch=15, batch_size=16, validation_data=(X_test, y_test), verbose=0)
 assert (history.history['val_acc'][(-1)] > 0.8)

@ keras_test def test_vector_classification ( ) : np . random . seed ( 1337 ) nb_hidden = 10 ( ( X_train , y_train ) , ( X_test , y_test ) ) = get_test_data ( nb_train = 500 , nb_test = 200 , input_shape = ( 20 , ) , classification = True , nb_class = 2 ) y_train = to_categorical ( y_train ) y_test = to_categorical ( y_test ) model = Sequential ( [ Dense ( nb_hidden , input_shape = ( X_train . shape [ ( - 1 ) ] , ) , activation = 'relu' ) , Dense ( y_train . shape [ ( - 1 ) ] , activation = 'softmax' ) ] ) model . compile ( loss = 'categorical_crossentropy' , optimizer = 'rmsprop' , metrics = [ 'accuracy' ] ) history = model . fit ( X_train , y_train , nb_epoch = 15 , batch_size = 16 , validation_data = ( X_test , y_test ) , verbose = 0 ) assert ( history . history [ 'val_acc' ] [ ( - 1 ) ] > 0.8 )
classify random float vectors into 2 classes with logistic regression using 2 layer neural network with relu hidden units .