#23657·keras

SimpleRNN and RandomGrayscale drop seed from get_config

Author: GargiGupta-ioCreated Sep 16, 2026Updated Sep 16, 2026
LabelsGood first issuetype:Buglayers

SimpleRNN and RandomGrayscale both accept a seed argument and both leave it out of get_config, so it is dropped whenever a model is saved and reloaded. Nothing raises; the reloaded model just stops reproducing the original one.

layer = layers.SimpleRNN(3, dropout=0.5, seed=1337)
layers.SimpleRNN.from_config(layer.get_config()).get_config()["seed"]
# KeyError

layer = layers.RandomGrayscale(factor=0.5, seed=1337)
layers.RandomGrayscale.from_config(layer.get_config()).seed
# None

Feeding the same batch through an original and a reloaded layer gives different results in both cases: SimpleRNN draws a different dropout mask, and RandomGrayscale grayscales a different subset of the images.

Each is the only member of its family that does this. LSTM and GRU serialize self.cell.seed, and SimpleRNNCell serializes self.seed, but SimpleRNN.get_config builds its own dict without it and then deletes the cell config that would otherwise have carried it. On the preprocessing side RandomFlip, RandomRotation, RandomContrast and RandomBrightness all serialize self.seed, while RandomGrayscale.get_config only adds factor.

run_layer_test does check config round-tripping, but it only round-trips the init_kwargs a test actually passes, and neither simple_rnn_test.test_basics nor random_grayscale_test.test_layer passes a seed, so there was never a seed there to lose.

Happy to send the PR.