Reputation: 1577
I am trying to reduce overfitting by adding noise and random mutations to my original data.
I have a function that mutates training data
x, y = generate_data()
I would like the each epoch to call it and train my model on the new data. The hope is to reduce overfitting.
history = model.fit(x, y, epochs=100, batch_size=64)
What is the best way to change the data for each new epoch?
Upvotes: 4
Views: 1639
Reputation: 839
model.fit has a shuffle argument and the default value is True. So it shuffles the samples at each epoch.
def fit(self, x, y, batch_size=32, epochs=10, verbose=1, callbacks=None,
validation_split=0., validation_data=None, shuffle=True,
class_weight=None, sample_weight=None, initial_epoch=0, **kwargs)
Upvotes: 0
Reputation: 855
Just a guess. Try:
for _ in range(num_epochs):
x, y = generate_data()
history = model.fit(x, y, epochs=1, batch_size=64)
Upvotes: 4