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

Put some error message when the year_list exceeds the size of the file we load so that it is clear what is happening #60

Open
georgemilosh opened this issue Feb 22, 2023 · 1 comment
Labels
invalid This doesn't seem right

Comments

@georgemilosh
Copy link
Owner

Command:

python hyperparameter_optimization.py study=test n_trials=6 year_list="range(200)"

Error message:

n on folder = './11--ResNet__True--batch_normalizations__True--batch_size__38--conv_channel_first__32--conv_dropouts__0.32--conv_l2coef__47235...' failed due to AttributeError("'NoneType' object has no attribute 'shape'")
Traceback (most recent call last):
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/Learn2_new.py", line 3040, in run
    score, info = k_fold_cross_val(folder, self.X, self.Y, **k_fold_cross_val_kwargs)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/ERA/utilities.py", line 234, in wrapper
    r = func(*args, **kwargs)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/ERA/utilities.py", line 196, in wrapper_inner
    r = func(*args, **kwargs)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/Learn2_new.py", line 2252, in k_fold_cross_val
    X_tr, Y_tr, X_va, Y_va = k_fold_cross_val_split(i, X, Y, nfolds=nfolds, val_folds=val_folds)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/ERA/utilities.py", line 234, in wrapper
    r = func(*args, **kwargs)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/ERA/utilities.py", line 196, in wrapper_inner
    r = func(*args, **kwargs)
  File "/ClimateDynamics/MediumSpace/ClimateLearningFR/gmiloshe/CESM/models/hypop_France_CNN_deep/t3-test/Learn2_new.py", line 1963, in k_fold_cross_val_split
    fold_len = arr[0].shape[0]//nfolds
AttributeError: 'NoneType' object has no attribute 'shape'

[I 2023-02-22 18:50:25,285] Trial 5 pruned. Run failed: pruning.
Completed 6 runs, 6 of which failed due to invalid network architecture
@AlessandroLovo
Copy link
Collaborator

This should not have happened due to year list problems:
The Plasim_Field.select_years function checks for invalid years

@ut.exec_time(logger)
    def select_years(self, year_list=None):
        '''
        Select a subset of years

        Parameters
        ----------
        year_list : array-like, optional
            list of the years to keep, by default None
        '''
        # check if the given year list is within the range of the data
        if year_list is not None:
            invalid_years = set(year_list) - set(self.field.time.dt.year.data)
            if invalid_years:
                raise IndexError(f'Data year range is {self.year_range} which does not include {pretty_set_of_int(invalid_years)}')
            self.field = self.field.sel(time=self.field.time.dt.year.isin(year_list))
            self.years = len(year_list)

So I think the error was somewhere else

@AlessandroLovo AlessandroLovo added the invalid This doesn't seem right label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants