def test_invalid_loss_or_metrics(self):
    num_classes = 5
    train_samples = 1000
    test_samples = 1000
    input_dim = 5
    model = keras.models.Sequential()
    model.add(keras.layers.Dense(10, input_shape=(input_dim,)))
    model.add(keras.layers.Activation('relu'))
    model.add(keras.layers.Dense(num_classes))
    model.add(keras.layers.Activation('softmax'))
    model.compile(loss='categorical_crossentropy', optimizer=RMSPropOptimizer(learning_rate=0.001))
    np.random.seed(1337)
    ((x_train, y_train), (_, _)) = testing_utils.get_test_data(train_samples=train_samples, test_samples=test_samples, input_shape=(input_dim,), num_classes=num_classes)
    with self.assertRaises(ValueError):
        model.fit(x_train, np.concatenate([y_train, y_train], axis=(- 1)))
    with self.assertRaises(TypeError):
        model.compile(loss='categorical_crossentropy', optimizer=RMSPropOptimizer(learning_rate=0.001), metrics=set(0))
    with self.assertRaises(ValueError):
        model.compile(loss=None, optimizer='rms')
def test_invalid_loss_or_metrics(self):
    num_classes = 5
    train_samples = 1000
    test_samples = 1000
    input_dim = 5
    model = keras.models.Sequential()
    model.add(keras.layers.Dense(10, input_shape=(input_dim,)))
    model.add(keras.layers.Activation('relu'))
    model.add(keras.layers.Dense(num_classes))
    model.add(keras.layers.Activation('softmax'))
    model.compile(loss='categorical_crossentropy', optimizer=RMSPropOptimizer(learning_rate=0.001))
    np.random.seed(1337)
    ((x_train, y_train), (_, _)) = testing_utils.get_test_data(train_samples=train_samples, test_samples=test_samples, input_shape=(input_dim,), num_classes=num_classes)
    with self.assertRaises(ValueError):
        model.fit(x_train, np.concatenate([y_train, y_train], axis=(- 1)))
    with self.assertRaises(TypeError):
        model.compile(loss='categorical_crossentropy', optimizer=RMSPropOptimizer(learning_rate=0.001), metrics=set(0))
    with self.assertRaises(ValueError):
        model.compile(loss=None, optimizer='rms')