def test_fit_on_arrays(self):
    a = keras.layers.Input(shape=(3,), name='input_a')
    b = keras.layers.Input(shape=(3,), name='input_b')
    dense = keras.layers.Dense(4, name='dense')
    c = dense(a)
    d = dense(b)
    e = keras.layers.Dropout(0.5, name='dropout')(c)
    model = keras.models.Model([a, b], [d, e])
    optimizer = RMSPropOptimizer(learning_rate=0.001)
    loss = 'mse'
    loss_weights = [1.0, 0.5]
    metrics = ['mae']
    model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights)
    input_a_np = np.random.random((10, 3))
    input_b_np = np.random.random((10, 3))
    output_d_np = np.random.random((10, 4))
    output_e_np = np.random.random((10, 4))
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=1)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=2, batch_size=5, verbose=2)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=1, batch_size=5, verbose=0)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=2, batch_size=5, verbose=1)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=2, batch_size=5, verbose=2)
    model.train_on_batch([input_a_np, input_b_np], [output_d_np, output_e_np])
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=2, batch_size=5, verbose=0, validation_split=0.2)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, epochs=1, batch_size=5, verbose=0)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, epochs=1, batch_size=5, verbose=1)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, validation_data=({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}), epochs=1, batch_size=5, verbose=0)
    model.train_on_batch({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np})
    loss = ['mae', 'mse']
    metrics = ['acc', 'mae']
    model.compile(optimizer, loss, metrics=metrics)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    loss = {'dense': 'mse', 'dropout': 'mae'}
    loss_weights = {'dense': 1.0, 'dropout': 0.5}
    metrics = {'dense': 'mse', 'dropout': 'mae'}
    model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    with self.assertRaises(AttributeError):
        model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, validation_data=([input_a_np, input_b_np], 0, 0), verbose=0)
    with self.assertRaises(ValueError):
        model.train_on_batch({'input_a': input_a_np}, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        model.train_on_batch([input_a_np], [output_d_np, output_e_np])
    with self.assertRaises(AttributeError):
        model.train_on_batch(1, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        model.train_on_batch(input_a_np, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        bad_input = np.random.random((11, 3))
        model.train_on_batch([bad_input, input_b_np], [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        bad_target = np.random.random((11, 4))
        model.train_on_batch([input_a_np, input_b_np], [bad_target, output_e_np])
    x = keras.layers.Input(shape=(3,), name='input_a')
    y = keras.layers.Dense(4)(x)
    model = keras.models.Model(x, y)
    model.compile(optimizer=RMSPropOptimizer(learning_rate=0.001), loss='mse')
    model.fit([input_a_np], output_d_np, epochs=1)
    with self.assertRaises(ValueError):
        model.fit([input_a_np, input_a_np], output_d_np, epochs=1)
def test_fit_on_arrays(self):
    a = keras.layers.Input(shape=(3,), name='input_a')
    b = keras.layers.Input(shape=(3,), name='input_b')
    dense = keras.layers.Dense(4, name='dense')
    c = dense(a)
    d = dense(b)
    e = keras.layers.Dropout(0.5, name='dropout')(c)
    model = keras.models.Model([a, b], [d, e])
    optimizer = RMSPropOptimizer(learning_rate=0.001)
    loss = 'mse'
    loss_weights = [1.0, 0.5]
    metrics = ['mae']
    model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights)
    input_a_np = np.random.random((10, 3))
    input_b_np = np.random.random((10, 3))
    output_d_np = np.random.random((10, 4))
    output_e_np = np.random.random((10, 4))
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=1)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=2, batch_size=5, verbose=2)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=1, batch_size=5, verbose=0)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=2, batch_size=5, verbose=1)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], validation_data=([input_a_np, input_b_np], [output_d_np, output_e_np]), epochs=2, batch_size=5, verbose=2)
    model.train_on_batch([input_a_np, input_b_np], [output_d_np, output_e_np])
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=2, batch_size=5, verbose=0, validation_split=0.2)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, epochs=1, batch_size=5, verbose=0)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, epochs=1, batch_size=5, verbose=1)
    model.fit({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}, validation_data=({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np}), epochs=1, batch_size=5, verbose=0)
    model.train_on_batch({'input_a': input_a_np, 'input_b': input_b_np}, {'dense': output_d_np, 'dropout': output_e_np})
    loss = ['mae', 'mse']
    metrics = ['acc', 'mae']
    model.compile(optimizer, loss, metrics=metrics)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    loss = {'dense': 'mse', 'dropout': 'mae'}
    loss_weights = {'dense': 1.0, 'dropout': 0.5}
    metrics = {'dense': 'mse', 'dropout': 'mae'}
    model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights)
    model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, batch_size=5, verbose=0)
    with self.assertRaises(AttributeError):
        model.fit([input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, validation_data=([input_a_np, input_b_np], 0, 0), verbose=0)
    with self.assertRaises(ValueError):
        model.train_on_batch({'input_a': input_a_np}, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        model.train_on_batch([input_a_np], [output_d_np, output_e_np])
    with self.assertRaises(AttributeError):
        model.train_on_batch(1, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        model.train_on_batch(input_a_np, [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        bad_input = np.random.random((11, 3))
        model.train_on_batch([bad_input, input_b_np], [output_d_np, output_e_np])
    with self.assertRaises(ValueError):
        bad_target = np.random.random((11, 4))
        model.train_on_batch([input_a_np, input_b_np], [bad_target, output_e_np])
    x = keras.layers.Input(shape=(3,), name='input_a')
    y = keras.layers.Dense(4)(x)
    model = keras.models.Model(x, y)
    model.compile(optimizer=RMSPropOptimizer(learning_rate=0.001), loss='mse')
    model.fit([input_a_np], output_d_np, epochs=1)
    with self.assertRaises(ValueError):
        model.fit([input_a_np, input_a_np], output_d_np, epochs=1)