Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #332 : Shallow copy data container before each epoch #333

Conversation

alexbrillant
Copy link
Contributor

@alexbrillant alexbrillant commented May 16, 2020

What it is

My pull request does:

Add a shallow copy in the fit_trial_split method inside the Trainer because the pipeline could change the reference of the data inputs directly, and change the values for the next epochs.

  def fit_trial_split(
           self,
           trial_split: TrialSplit,
           train_data_container: DataContainer,
           validation_data_container: DataContainer,
           context: ExecutionContext
   ) -> TrialSplit:
       """
       Train pipeline using the training data container.
       Track training, and validation metrics for each epoch.

       :param train_data_container: train data container
       :param validation_data_container: validation data container
       :param trial_split: trial to execute
       :param context: execution context

       :return: executed trial
       """
       early_stopping = False

       for i in range(self.epochs):
           self.print_func('\nepoch {}/{}'.format(i + 1, self.epochs))

           # shallow copy here to create a new reference for the data inputs inside the data container. 
           trial_split = trial_split.fit_trial_split(train_data_container.copy(), context)
           y_pred_train = trial_split.predict_with_pipeline(train_data_container.copy(), context)
           y_pred_val = trial_split.predict_with_pipeline(validation_data_container.copy(), context)

           if self.callbacks.call(
                   trial=trial_split,
                   epoch_number=i,
                   total_epochs=self.epochs,
                   input_train=train_data_container,
                   pred_train=y_pred_train,
                   input_val=validation_data_container,
                   pred_val=y_pred_val,
                   is_finished_and_fitted=early_stopping
           ):
               break

       return trial_split

@cla-bot cla-bot bot added the cla-signed label May 16, 2020
@alexbrillant alexbrillant deleted the fix-shallow-copy-data-container-automl-loop branch May 16, 2020 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant