def test_dataset_input_shape_validation(self):
    with self.cached_session():
        model = get_model()
        optimizer = rmsprop.RMSPropOptimizer(learning_rate=0.001)
        loss = 'mse'
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:1', '/device:GPU:0'])
        model.compile(optimizer, loss, distribute=strategy)
        inputs = np.zeros((10, 3), dtype=np.float32)
        targets = np.zeros((10, 4), dtype=np.float32)
        dataset = dataset_ops.Dataset.from_tensor_slices((inputs, targets))
        dataset = dataset.repeat(100)
        with self.assertRaisesRegexp(ValueError, 'expected input to have shape'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0)
        inputs = np.zeros((10, 5), dtype=np.float32)
        targets = np.zeros((10, 4), dtype=np.float32)
        dataset = dataset_ops.Dataset.from_tensor_slices((inputs, targets))
        dataset = dataset.repeat(100)
        dataset = dataset.batch(10)
        with self.assertRaisesRegexp(ValueError, 'expected input to have shape'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0)
def test_dataset_input_shape_validation(self):
    with self.cached_session():
        model = get_model()
        optimizer = rmsprop.RMSPropOptimizer(learning_rate=0.001)
        loss = 'mse'
        strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:1', '/device:GPU:0'])
        model.compile(optimizer, loss, distribute=strategy)
        inputs = np.zeros((10, 3), dtype=np.float32)
        targets = np.zeros((10, 4), dtype=np.float32)
        dataset = dataset_ops.Dataset.from_tensor_slices((inputs, targets))
        dataset = dataset.repeat(100)
        with self.assertRaisesRegexp(ValueError, 'expected input to have shape'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0)
        inputs = np.zeros((10, 5), dtype=np.float32)
        targets = np.zeros((10, 4), dtype=np.float32)
        dataset = dataset_ops.Dataset.from_tensor_slices((inputs, targets))
        dataset = dataset.repeat(100)
        dataset = dataset.batch(10)
        with self.assertRaisesRegexp(ValueError, 'expected input to have shape'):
            model.fit(dataset, epochs=1, steps_per_epoch=2, verbose=0)