From b491670ca8426708676c680f2978dc6e48c0c6cf Mon Sep 17 00:00:00 2001 From: isaacmg Date: Tue, 7 May 2024 13:46:52 -0400 Subject: [PATCH 01/14] Revert "re-add changes in crossformer commit without junk" This reverts commit 47d2b439ee4e4550f7b073e6aa48a824a55ffdac. --- .circleci/config.yml | 2 +- flood_forecast/transformer_xl/cross_former.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 577315f08..917c5f0ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -334,7 +334,7 @@ jobs: coverage run flood_forecast/trainer.py -p tests/dsanet.json echo -e 'running trainer_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/decoder_test.json - echo -e 'running trainer_full_transformer_test' + echo -e 'running trainer_full_transformer_test \n' coverage run flood_forecast/trainer.py -p tests/full_transformer.json - store_test_results: diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index 50c082b20..cba0e7552 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -19,7 +19,6 @@ def __init__( e_layers=3, dropout=0.0, baseline=False, - n_targs=None, device=torch.device("cuda:0"), ): """Crossformer: Transformer Utilizing Cross-Dimension Dependency for Multivariate Time Series Forecasting. @@ -58,7 +57,6 @@ def __init__( self.out_len = forecast_length self.seg_len = seg_len self.merge_win = win_size - self.n_targs = n_time_series if n_targs is None else n_targs self.baseline = baseline @@ -128,9 +126,7 @@ def forward(self, x_seq: torch.Tensor): ) predict_y = self.decoder(dec_in, enc_out) - result = base + predict_y[:, : self.out_len, :] - res = result[:, :, :self.n_targs] - return res + return base + predict_y[:, : self.out_len, :] class SegMerging(nn.Module): From 94c1f4286c7195a5aa012a4820cad1b03157dc9e Mon Sep 17 00:00:00 2001 From: isaacmg Date: Tue, 7 May 2024 13:47:52 -0400 Subject: [PATCH 02/14] re-adding crossformer changes --- .circleci/config.yml | 1 + flood_forecast/transformer_xl/cross_former.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 917c5f0ab..5391c2fcb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -319,6 +319,7 @@ jobs: name: Trainer1 tests when: always command: | + echo -e 'running test_informer \n' coverage run flood_forecast/trainer.py -p tests/test_informer.json coverage run flood_forecast/trainer.py -p tests/test_iTransformer.json coverage run flood_forecast/trainer.py -p tests/tsmixer_test.json diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index cba0e7552..50c082b20 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -19,6 +19,7 @@ def __init__( e_layers=3, dropout=0.0, baseline=False, + n_targs=None, device=torch.device("cuda:0"), ): """Crossformer: Transformer Utilizing Cross-Dimension Dependency for Multivariate Time Series Forecasting. @@ -57,6 +58,7 @@ def __init__( self.out_len = forecast_length self.seg_len = seg_len self.merge_win = win_size + self.n_targs = n_time_series if n_targs is None else n_targs self.baseline = baseline @@ -126,7 +128,9 @@ def forward(self, x_seq: torch.Tensor): ) predict_y = self.decoder(dec_in, enc_out) - return base + predict_y[:, : self.out_len, :] + result = base + predict_y[:, : self.out_len, :] + res = result[:, :, :self.n_targs] + return res class SegMerging(nn.Module): From dcc0dd7201ee46f7d06cb646b250751db3578932 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:23:11 -0400 Subject: [PATCH 03/14] add core code and docs test Number of changes to docs and circle --- .circleci/config.yml | 67 +++++++++++++++---- docs/source/d_linear.rst | 5 ++ docs/source/itransformer.rst | 5 ++ flood_forecast/model_dict_function.py | 2 +- .../preprocessing/temporal_feats.py | 2 +- 5 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 docs/source/d_linear.rst create mode 100644 docs/source/itransformer.rst diff --git a/.circleci/config.yml b/.circleci/config.yml index 5391c2fcb..93f523027 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: python-executor: docker: - - image: cimg/python:3.10.3 + - image: cimg/python:3.11.1 working_directory: ~/repo @@ -274,14 +274,7 @@ jobs: coverage run flood_forecast/trainer.py -p tests/probabilistic_linear_regression_test.json echo -e 'running meta-data fusion' coverage run flood_forecast/trainer.py -p tests/meta_data_test.json - echo -e 'running da_rnn_test \n' - coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' - coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_lstm_test \n ' - coverage run flood_forecast/trainer.py -p tests/lstm_test.json - echo -e 'running trainer_multi_test \n' - coverage run flood_forecast/trainer.py -p tests/multi_test.json + - store_test_results: path: test-results @@ -333,10 +326,6 @@ jobs: coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json coverage run flood_forecast/trainer.py -p tests/test_dual.json coverage run flood_forecast/trainer.py -p tests/dsanet.json - echo -e 'running trainer_decoder_test \n' - coverage run flood_forecast/trainer.py -p tests/decoder_test.json - echo -e 'running trainer_full_transformer_test \n' - coverage run flood_forecast/trainer.py -p tests/full_transformer.json - store_test_results: path: test-results @@ -350,6 +339,54 @@ jobs: when: always command: bash <(curl -s https://codecov.io/bash) -cF python +trainer_test2: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - restore_cache: # ensure this step occurs *before* installing dependencies + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + + - run: + name: install dependencies + command: | + pip install pipenv + pip install --force-reinstall --upgrade --quiet -r requirements.txt + pip install coverage + python setup.py develop --no-deps + - save_cache: + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + paths: + - ~/.local + + - run: + name: Trainer tests 2 + when: always + command: | + echo -e 'running trainer_lstm_test \n ' + coverage run flood_forecast/trainer.py -p tests/lstm_test.json + echo -e 'running trainer_multi_test \n' + coverage run flood_forecast/trainer.py -p tests/multi_test.json + echo -e 'running trainer_full_transformer_test \n' + coverage run flood_forecast/trainer.py -p tests/full_transformer.json + echo -e 'running da_rnn_test \n' + coverage run flood_forecast/trainer.py -p tests/da_rnn.json + echo -e 'running auto test \n' + coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json + echo -e 'running trainer_decoder_test \n' + coverage run flood_forecast/trainer.py -p tests/decoder_test.json + - store_test_results: + path: test-results + + - store_artifacts: + path: test-results + destination: test-results-trainer + + - run: + name: upload results + when: always + command: bash <(curl -s https://codecov.io/bash) -cF python + plot_test: <<: *defaults steps: @@ -421,3 +458,7 @@ workflows: - trainer_test1: requires: - setup_and_install + -trainer_test2: + requires: + - setup_and_install + diff --git a/docs/source/d_linear.rst b/docs/source/d_linear.rst new file mode 100644 index 000000000..048a4cb11 --- /dev/null +++ b/docs/source/d_linear.rst @@ -0,0 +1,5 @@ +Dummy Torch Model +================== + +.. automodule:: flood_forecast.basic.d_n_linear + :members: diff --git a/docs/source/itransformer.rst b/docs/source/itransformer.rst new file mode 100644 index 000000000..d049dd2f3 --- /dev/null +++ b/docs/source/itransformer.rst @@ -0,0 +1,5 @@ +I-Transformer Model +================== + +.. automodule:: flood_forecast.transformer_xl.itransformer + :members: diff --git a/flood_forecast/model_dict_function.py b/flood_forecast/model_dict_function.py index 598df9bc7..acf2cd2bb 100644 --- a/flood_forecast/model_dict_function.py +++ b/flood_forecast/model_dict_function.py @@ -27,7 +27,7 @@ """ -Utility dictionaries to map a string to a c class +Utility dictionaries to map a string to a class """ pytorch_model_dict = { "MultiAttnHeadSimple": MultiAttnHeadSimple, diff --git a/flood_forecast/preprocessing/temporal_feats.py b/flood_forecast/preprocessing/temporal_feats.py index 1b9609550..60a758542 100644 --- a/flood_forecast/preprocessing/temporal_feats.py +++ b/flood_forecast/preprocessing/temporal_feats.py @@ -14,7 +14,7 @@ def create_feature(key: str, value: str, df: pd.DataFrame, dt_column: str): :type df: pd.DataFrame :param dt_column: The name of the datetime column :type dt_column: str - :return: The dataframe with the newly added column. + :return: The dataframe with the newly added columns. :rtype: pd.DataFrame """ if key == "day_of_week": From b78d80c5af2b083130331943ed97864c29cad1ee Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:26:57 -0400 Subject: [PATCH 04/14] fixing other core code --- docs/source/basic_utils.rst | 2 ++ docs/source/d_linear.rst | 2 +- docs/source/meta_models.rst | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/basic_utils.rst b/docs/source/basic_utils.rst index ebf404532..23b69874b 100644 --- a/docs/source/basic_utils.rst +++ b/docs/source/basic_utils.rst @@ -3,3 +3,5 @@ Basic GCP Utils .. automodule:: flood_forecast.gcp_integration.basic_utils :members: + +The basic utilities in order to connect to GCP. \ No newline at end of file diff --git a/docs/source/d_linear.rst b/docs/source/d_linear.rst index 048a4cb11..968a10c80 100644 --- a/docs/source/d_linear.rst +++ b/docs/source/d_linear.rst @@ -1,4 +1,4 @@ -Dummy Torch Model +D and Linear Models ================== .. automodule:: flood_forecast.basic.d_n_linear diff --git a/docs/source/meta_models.rst b/docs/source/meta_models.rst index 4be03bdd8..e287f4d77 100644 --- a/docs/source/meta_models.rst +++ b/docs/source/meta_models.rst @@ -1,4 +1,4 @@ -Meta Models +Meta-Models ========================= .. automodule:: flood_forecast.meta_models.merging_model From 551e95134a3328fbcb8a85e8c32ac98e592753e8 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:27:12 -0400 Subject: [PATCH 05/14] Revert "fixing other core code" This reverts commit b78d80c5af2b083130331943ed97864c29cad1ee. --- docs/source/basic_utils.rst | 2 -- docs/source/d_linear.rst | 2 +- docs/source/meta_models.rst | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/source/basic_utils.rst b/docs/source/basic_utils.rst index 23b69874b..ebf404532 100644 --- a/docs/source/basic_utils.rst +++ b/docs/source/basic_utils.rst @@ -3,5 +3,3 @@ Basic GCP Utils .. automodule:: flood_forecast.gcp_integration.basic_utils :members: - -The basic utilities in order to connect to GCP. \ No newline at end of file diff --git a/docs/source/d_linear.rst b/docs/source/d_linear.rst index 968a10c80..048a4cb11 100644 --- a/docs/source/d_linear.rst +++ b/docs/source/d_linear.rst @@ -1,4 +1,4 @@ -D and Linear Models +Dummy Torch Model ================== .. automodule:: flood_forecast.basic.d_n_linear diff --git a/docs/source/meta_models.rst b/docs/source/meta_models.rst index e287f4d77..4be03bdd8 100644 --- a/docs/source/meta_models.rst +++ b/docs/source/meta_models.rst @@ -1,4 +1,4 @@ -Meta-Models +Meta Models ========================= .. automodule:: flood_forecast.meta_models.merging_model From d505d6a44467a8917898f3ea656148d3ffd862af Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:28:11 -0400 Subject: [PATCH 06/14] fixing the core code 4 fixing all tehsa qwgo3g3njrg[jo3 and stuff --- docs/source/basic_ae.rst | 2 +- docs/source/crossformer.rst | 4 ++++ docs/source/custom_opt.rst | 1 - docs/source/d_linear.rst | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 docs/source/crossformer.rst diff --git a/docs/source/basic_ae.rst b/docs/source/basic_ae.rst index e9f147792..c9b0eecf7 100644 --- a/docs/source/basic_ae.rst +++ b/docs/source/basic_ae.rst @@ -4,4 +4,4 @@ Simple AE .. automodule:: flood_forecast.meta_models.basic_ae :members: -A simple auto-encoder +A simple auto-encoder model. diff --git a/docs/source/crossformer.rst b/docs/source/crossformer.rst new file mode 100644 index 000000000..ea77456e5 --- /dev/null +++ b/docs/source/crossformer.rst @@ -0,0 +1,4 @@ +Crossformer +========================= +.. automodule:: flood_forecast.transformer_xl.crossformer + :members: \ No newline at end of file diff --git a/docs/source/custom_opt.rst b/docs/source/custom_opt.rst index 81ea903bd..dd7008614 100644 --- a/docs/source/custom_opt.rst +++ b/docs/source/custom_opt.rst @@ -3,4 +3,3 @@ Custom Optimizations .. automodule:: flood_forecast.custom.custom_opt :members: -sss \ No newline at end of file diff --git a/docs/source/d_linear.rst b/docs/source/d_linear.rst index 048a4cb11..c2368ff4c 100644 --- a/docs/source/d_linear.rst +++ b/docs/source/d_linear.rst @@ -1,4 +1,4 @@ -Dummy Torch Model +D and N LInear ================== .. automodule:: flood_forecast.basic.d_n_linear From 10f9e42aca93b3700b4c41a2f19f05114960cb22 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:28:32 -0400 Subject: [PATCH 07/14] fixing to itransformer --- docs/source/index.rst | 1 + flood_forecast/preprocessing/pytorch_loaders.py | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 719989942..b169c3b7f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -64,6 +64,7 @@ of datasets. This documentation describes the internal Python code that makes up :caption: TransformerXL: dummy_torch + itransformer lower_upper_config multi_head_base transformer_basic diff --git a/flood_forecast/preprocessing/pytorch_loaders.py b/flood_forecast/preprocessing/pytorch_loaders.py index 9829bb92a..55b9879d5 100644 --- a/flood_forecast/preprocessing/pytorch_loaders.py +++ b/flood_forecast/preprocessing/pytorch_loaders.py @@ -644,7 +644,7 @@ def get_item_auto_encoder(self, idx): return the_seq.float(), the_seq.float() def pad_input_data(self, sequence: int): - """Pads a sequence to a specified length + """Pads a sequence to a specified length. """ if self.pad_length > sequence.shape[0]: pad_dim = self.pad_length - sequence.shape[0] @@ -657,13 +657,6 @@ def __getitem__(self, idx: int): return tasks[self.task](idx) -class CSVResultsHolder(object): - def __init__(self, historical_rows, all_rows_orig, targ_idx) -> None: - self.historical_rows = historical_rows - self.all_rows_orig = all_rows_orig - self.targ_idx = targ_idx - - class SeriesIDTestLoader(CSVSeriesIDLoader): def __init__(self, series_id_col: str, main_params: dict, return_method: str, forecast_total=336, return_all=True): """_summary_ @@ -672,11 +665,11 @@ def __init__(self, series_id_col: str, main_params: dict, return_method: str, fo :type series_id_col: str :param main_params: The core params used to instantiate the CSVSeriesIDLoader :type main_params: dict - :param return_method: _description_D + :param return_method: What method to return to. :type return_method: str :param return_all: _description_, defaults to True :type return_all: bool, optional - :param forecast_total: _description_, defaults to 336 + :param forecast_total: The total length to forecast, defaults to 336 :type forecast_total: int, optional """ super().__init__(series_id_col, main_params, return_method, return_all) From d54ae98df0ea62b91cf767daf16e991ef6600cb4 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:35:32 -0400 Subject: [PATCH 08/14] fixing parsing errors --- .circleci/config.yml | 98 +++++++++++++++++++-------------------- docs/source/inference.rst | 5 +- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 93f523027..23bcc6fe7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: python-executor: docker: - - image: cimg/python:3.11.1 + - image: cimg/python:3.11 working_directory: ~/repo @@ -339,53 +339,53 @@ jobs: when: always command: bash <(curl -s https://codecov.io/bash) -cF python -trainer_test2: - <<: *defaults - steps: - - attach_workspace: - at: ~/repo - - restore_cache: # ensure this step occurs *before* installing dependencies - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - - - run: - name: install dependencies - command: | - pip install pipenv - pip install --force-reinstall --upgrade --quiet -r requirements.txt - pip install coverage - python setup.py develop --no-deps - - save_cache: - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - paths: - - ~/.local - - - run: - name: Trainer tests 2 - when: always - command: | - echo -e 'running trainer_lstm_test \n ' - coverage run flood_forecast/trainer.py -p tests/lstm_test.json - echo -e 'running trainer_multi_test \n' - coverage run flood_forecast/trainer.py -p tests/multi_test.json - echo -e 'running trainer_full_transformer_test \n' - coverage run flood_forecast/trainer.py -p tests/full_transformer.json - echo -e 'running da_rnn_test \n' - coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' - coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' - coverage run flood_forecast/trainer.py -p tests/decoder_test.json - - store_test_results: - path: test-results - - - store_artifacts: - path: test-results - destination: test-results-trainer - - - run: - name: upload results - when: always - command: bash <(curl -s https://codecov.io/bash) -cF python + trainer_test2: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - restore_cache: # ensure this step occurs *before* installing dependencies + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + + - run: + name: install dependencies + command: | + pip install pipenv + pip install --force-reinstall --upgrade --quiet -r requirements.txt + pip install coverage + python setup.py develop --no-deps + - save_cache: + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + paths: + - ~/.local + + - run: + name: Trainer tests 2 + when: always + command: | + echo -e 'running trainer_lstm_test \n ' + coverage run flood_forecast/trainer.py -p tests/lstm_test.json + echo -e 'running trainer_multi_test \n' + coverage run flood_forecast/trainer.py -p tests/multi_test.json + echo -e 'running trainer_full_transformer_test \n' + coverage run flood_forecast/trainer.py -p tests/full_transformer.json + echo -e 'running da_rnn_test \n' + coverage run flood_forecast/trainer.py -p tests/da_rnn.json + echo -e 'running auto test \n' + coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json + echo -e 'running trainer_decoder_test \n' + coverage run flood_forecast/trainer.py -p tests/decoder_test.json + - store_test_results: + path: test-results + + - store_artifacts: + path: test-results + destination: test-results-trainer + + - run: + name: upload results + when: always + command: bash <(curl -s https://codecov.io/bash) -cF python plot_test: <<: *defaults @@ -458,7 +458,7 @@ workflows: - trainer_test1: requires: - setup_and_install - -trainer_test2: + - trainer_test2: requires: - setup_and_install diff --git a/docs/source/inference.rst b/docs/source/inference.rst index 1fc82cf97..419c4f440 100644 --- a/docs/source/inference.rst +++ b/docs/source/inference.rst @@ -1,9 +1,8 @@ Inference ========================= -This API makes it easy to run inference on trained PyTorchForecast modules. To use this code you -need three main files: your model's configuration file, a CSV containing your data, and a path to -your model weights. +The Flow Forecast Inference API makes it easy to run inference on trained PyTorchForecast modules. To use this code you +need three main files: your model's configuration file, a CSV containing your data, and a path to your model weights. .. code-block:: python :caption: example initialization From 45cd25bfdc3fd8d8a1c96103e4b8a3e39b208070 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:48:00 -0400 Subject: [PATCH 09/14] Revert "fixing parsing errors" This reverts commit d54ae98df0ea62b91cf767daf16e991ef6600cb4. --- .circleci/config.yml | 98 +++++++++++++++++++-------------------- docs/source/inference.rst | 5 +- 2 files changed, 52 insertions(+), 51 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23bcc6fe7..93f523027 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: python-executor: docker: - - image: cimg/python:3.11 + - image: cimg/python:3.11.1 working_directory: ~/repo @@ -339,53 +339,53 @@ jobs: when: always command: bash <(curl -s https://codecov.io/bash) -cF python - trainer_test2: - <<: *defaults - steps: - - attach_workspace: - at: ~/repo - - restore_cache: # ensure this step occurs *before* installing dependencies - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - - - run: - name: install dependencies - command: | - pip install pipenv - pip install --force-reinstall --upgrade --quiet -r requirements.txt - pip install coverage - python setup.py develop --no-deps - - save_cache: - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - paths: - - ~/.local - - - run: - name: Trainer tests 2 - when: always - command: | - echo -e 'running trainer_lstm_test \n ' - coverage run flood_forecast/trainer.py -p tests/lstm_test.json - echo -e 'running trainer_multi_test \n' - coverage run flood_forecast/trainer.py -p tests/multi_test.json - echo -e 'running trainer_full_transformer_test \n' - coverage run flood_forecast/trainer.py -p tests/full_transformer.json - echo -e 'running da_rnn_test \n' - coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' - coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' - coverage run flood_forecast/trainer.py -p tests/decoder_test.json - - store_test_results: - path: test-results - - - store_artifacts: - path: test-results - destination: test-results-trainer - - - run: - name: upload results - when: always - command: bash <(curl -s https://codecov.io/bash) -cF python +trainer_test2: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - restore_cache: # ensure this step occurs *before* installing dependencies + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + + - run: + name: install dependencies + command: | + pip install pipenv + pip install --force-reinstall --upgrade --quiet -r requirements.txt + pip install coverage + python setup.py develop --no-deps + - save_cache: + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + paths: + - ~/.local + + - run: + name: Trainer tests 2 + when: always + command: | + echo -e 'running trainer_lstm_test \n ' + coverage run flood_forecast/trainer.py -p tests/lstm_test.json + echo -e 'running trainer_multi_test \n' + coverage run flood_forecast/trainer.py -p tests/multi_test.json + echo -e 'running trainer_full_transformer_test \n' + coverage run flood_forecast/trainer.py -p tests/full_transformer.json + echo -e 'running da_rnn_test \n' + coverage run flood_forecast/trainer.py -p tests/da_rnn.json + echo -e 'running auto test \n' + coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json + echo -e 'running trainer_decoder_test \n' + coverage run flood_forecast/trainer.py -p tests/decoder_test.json + - store_test_results: + path: test-results + + - store_artifacts: + path: test-results + destination: test-results-trainer + + - run: + name: upload results + when: always + command: bash <(curl -s https://codecov.io/bash) -cF python plot_test: <<: *defaults @@ -458,7 +458,7 @@ workflows: - trainer_test1: requires: - setup_and_install - - trainer_test2: + -trainer_test2: requires: - setup_and_install diff --git a/docs/source/inference.rst b/docs/source/inference.rst index 419c4f440..1fc82cf97 100644 --- a/docs/source/inference.rst +++ b/docs/source/inference.rst @@ -1,8 +1,9 @@ Inference ========================= -The Flow Forecast Inference API makes it easy to run inference on trained PyTorchForecast modules. To use this code you -need three main files: your model's configuration file, a CSV containing your data, and a path to your model weights. +This API makes it easy to run inference on trained PyTorchForecast modules. To use this code you +need three main files: your model's configuration file, a CSV containing your data, and a path to +your model weights. .. code-block:: python :caption: example initialization From a52dde0d3a80e749f1abf0a35fc9dbe418cd9bca Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 18:54:48 -0400 Subject: [PATCH 10/14] re-fix parsing errors --- .circleci/config.yml | 98 +++++++++---------- flood_forecast/transformer_xl/cross_former.py | 10 +- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 93f523027..23bcc6fe7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: python-executor: docker: - - image: cimg/python:3.11.1 + - image: cimg/python:3.11 working_directory: ~/repo @@ -339,53 +339,53 @@ jobs: when: always command: bash <(curl -s https://codecov.io/bash) -cF python -trainer_test2: - <<: *defaults - steps: - - attach_workspace: - at: ~/repo - - restore_cache: # ensure this step occurs *before* installing dependencies - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - - - run: - name: install dependencies - command: | - pip install pipenv - pip install --force-reinstall --upgrade --quiet -r requirements.txt - pip install coverage - python setup.py develop --no-deps - - save_cache: - key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} - paths: - - ~/.local - - - run: - name: Trainer tests 2 - when: always - command: | - echo -e 'running trainer_lstm_test \n ' - coverage run flood_forecast/trainer.py -p tests/lstm_test.json - echo -e 'running trainer_multi_test \n' - coverage run flood_forecast/trainer.py -p tests/multi_test.json - echo -e 'running trainer_full_transformer_test \n' - coverage run flood_forecast/trainer.py -p tests/full_transformer.json - echo -e 'running da_rnn_test \n' - coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' - coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' - coverage run flood_forecast/trainer.py -p tests/decoder_test.json - - store_test_results: - path: test-results - - - store_artifacts: - path: test-results - destination: test-results-trainer - - - run: - name: upload results - when: always - command: bash <(curl -s https://codecov.io/bash) -cF python + trainer_test2: + <<: *defaults + steps: + - attach_workspace: + at: ~/repo + - restore_cache: # ensure this step occurs *before* installing dependencies + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + + - run: + name: install dependencies + command: | + pip install pipenv + pip install --force-reinstall --upgrade --quiet -r requirements.txt + pip install coverage + python setup.py develop --no-deps + - save_cache: + key: requirements-v2-{{ .Branch }}-{{ checksum "requirements.txt" }} + paths: + - ~/.local + + - run: + name: Trainer tests 2 + when: always + command: | + echo -e 'running trainer_lstm_test \n ' + coverage run flood_forecast/trainer.py -p tests/lstm_test.json + echo -e 'running trainer_multi_test \n' + coverage run flood_forecast/trainer.py -p tests/multi_test.json + echo -e 'running trainer_full_transformer_test \n' + coverage run flood_forecast/trainer.py -p tests/full_transformer.json + echo -e 'running da_rnn_test \n' + coverage run flood_forecast/trainer.py -p tests/da_rnn.json + echo -e 'running auto test \n' + coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json + echo -e 'running trainer_decoder_test \n' + coverage run flood_forecast/trainer.py -p tests/decoder_test.json + - store_test_results: + path: test-results + + - store_artifacts: + path: test-results + destination: test-results-trainer + + - run: + name: upload results + when: always + command: bash <(curl -s https://codecov.io/bash) -cF python plot_test: <<: *defaults @@ -458,7 +458,7 @@ workflows: - trainer_test1: requires: - setup_and_install - -trainer_test2: + - trainer_test2: requires: - setup_and_install diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index 50c082b20..ac0192db9 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -33,7 +33,7 @@ def __init__( :type forecast_length: int :param seg_len: Parameter specific to Crossformer, forecast_history must be divisible by seg_len :type seg_len: int - :param win_size: _description_, defaults to 4 + :param win_size: The window size for the segment merge mechanism, defaults to 4 (original paper used 2) :type win_size: int, optional :param factor: _description_, defaults to 10 :type factor: int, optional @@ -41,13 +41,13 @@ def __init__( :type d_model: int, optional :param d_ff: _description_, defaults to 1024 :type d_ff: int, optional - :param n_heads: _description_, defaults to 8 + :param n_heads: The number of heads in the multi-head attention mechanism, defaults to 8 :type n_heads: int, optional - :param e_layers: _description_, defaults to 3 + :param e_layers: The number of encoder layers, defaults to 3 :type e_layers: int, optional - :param dropout: _description_, defaults to 0.0 + :param dropout: The amount of dropout to use when training the model, defaults to 0.0 :type dropout: float, optional - :param baseline: _description_, defaults to False + :param baseline: A boolean of whether to use mean of past time series , defaults to False :type baseline: bool, optional :param device: _description_, defaults to torch.device("cuda:0") :type device: str, optional From 63f5d5d912708c27e2c0224500eb7a51d57ca8f2 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Thu, 9 May 2024 19:29:30 -0400 Subject: [PATCH 11/14] clean up print statements/debug . and fix epochs --- flood_forecast/evaluator.py | 3 --- flood_forecast/transformer_xl/informer.py | 3 --- flood_forecast/transformer_xl/transformer_bottleneck.py | 4 ---- tests/custom_encode.json | 2 +- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/flood_forecast/evaluator.py b/flood_forecast/evaluator.py index 65189c037..362caf2fd 100644 --- a/flood_forecast/evaluator.py +++ b/flood_forecast/evaluator.py @@ -526,7 +526,6 @@ def generate_predictions( history_dim = history else: history_dim = history.unsqueeze(0).to(model.device) - print("Add debugging crap below") if decoder_params is None: end_tensor = generate_predictions_non_decoded( model, df, test_data, history_dim, forecast_length, hours_to_forecast, @@ -615,8 +614,6 @@ def generate_predictions_non_decoded( end_tensor = torch.cat(all_tensor, axis=0).to("cpu").detach()[:-remainder] else: end_tensor = torch.cat(all_tensor, axis=0).to("cpu").detach() - - print(end_tensor.shape) # Dimension now is (n_time_steps_to_forecast_steps)!! i.e [16] return end_tensor diff --git a/flood_forecast/transformer_xl/informer.py b/flood_forecast/transformer_xl/informer.py index fb8989999..a0f90b214 100644 --- a/flood_forecast/transformer_xl/informer.py +++ b/flood_forecast/transformer_xl/informer.py @@ -124,10 +124,7 @@ def forward(self, x_enc: torch.Tensor, x_mark_enc, x_dec, x_mark_dec, """ enc_out = self.enc_embedding(x_enc, x_mark_enc) enc_out, _ = self.encoder(enc_out, attn_mask=enc_self_mask) - print(type(enc_out)) - print("thing above") dec_out = self.dec_embedding(x_dec, x_mark_dec) - print(type(dec_out)) dec_out = self.decoder(dec_out, enc_out, x_mask=dec_self_mask, cross_mask=dec_enc_mask) dec_out = self.projection(dec_out) # dec_out = self.end_conv1(dec_out) diff --git a/flood_forecast/transformer_xl/transformer_bottleneck.py b/flood_forecast/transformer_xl/transformer_bottleneck.py index c03a047b4..425809fe8 100644 --- a/flood_forecast/transformer_xl/transformer_bottleneck.py +++ b/flood_forecast/transformer_xl/transformer_bottleneck.py @@ -268,10 +268,6 @@ def forward(self, series_id: int, x: torch.Tensor): embedding_sum = torch.zeros(batch_size, length) embedding_sum = embedding_sum.fill_(series_id).type(torch.LongTensor).to(self.device) embedding_sum = self.id_embed(embedding_sum) - print("shape below") - print(embedding_sum.shape) - print(x.shape) - print(series_id) position = torch.tensor(torch.arange(length), dtype=torch.long).to(self.device) po_embedding = self.po_embed(position) embedding_sum[:] = po_embedding diff --git a/tests/custom_encode.json b/tests/custom_encode.json index 353910ab3..f7f7927c4 100644 --- a/tests/custom_encode.json +++ b/tests/custom_encode.json @@ -37,7 +37,7 @@ }, "lr": 0.3, - "epochs": 30, + "epochs": 2, "batch_size":4 }, From 19899d65bde576f458039a00fbb71ea952eab9ba Mon Sep 17 00:00:00 2001 From: isaacmg Date: Wed, 15 May 2024 10:24:02 -0400 Subject: [PATCH 12/14] echo statements + docs --- .circleci/config.yml | 22 +++++++++++++++---- docs/source/index.rst | 4 ++-- flood_forecast/transformer_xl/cross_former.py | 11 +++++----- .../transformer_xl/data_embedding.py | 1 + 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23bcc6fe7..1b1ea5c6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -254,11 +254,13 @@ jobs: command: | echo -e 'GRU Vanilla test' coverage run flood_forecast/trainer.py -p tests/gru_vanilla.json + echo -e 'Running classification test' coverage run flood_forecast/trainer.py -p tests/classification_test.json + echo -e 'Running informer single test' coverage run flood_forecast/trainer.py -p tests/test_inf_single.json - echo -e 'test informer single target' - echo -e 'test multi informer' + echo -e 'Running transformer_gaussian test' coverage run flood_forecast/trainer.py -p tests/transformer_gaussian.json + echo -e 'Running multi_decoder_test.json' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json echo -e 'training multi-task-decoder' coverage run flood_forecast/trainer.py -p tests/multitask_decoder.json @@ -314,17 +316,29 @@ jobs: command: | echo -e 'running test_informer \n' coverage run flood_forecast/trainer.py -p tests/test_informer.json + echo -e 'running test_iTransformer \n' coverage run flood_forecast/trainer.py -p tests/test_iTransformer.json + echo -e 'running tsmixer_test \n' coverage run flood_forecast/trainer.py -p tests/tsmixer_test.json + echo -e 'running transformer_b_series.json \n' coverage run flood_forecast/trainer.py -p tests/transformer_b_series.json + echo -e 'running crossfroer.json \n' coverage run flood_forecast/trainer.py -p tests/cross_former.json + echo -e 'running nlinear.json \n' coverage run flood_forecast/trainer.py -p tests/nlinear.json + echo -e 'running dsanet_3\n' coverage run flood_forecast/trainer.py -p tests/dsanet_3.json + echo -e 'running variable_autoencoderl.json\n' coverage run flood_forecast/trainer.py -p tests/variable_autoencoderl.json + echo -e 'running dlinear\n' coverage run flood_forecast/trainer.py -p tests/dlinear.json + echo -e 'running custom_encode.json\n' coverage run flood_forecast/trainer.py -p tests/custom_encode.json + echo -e 'running multi_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json + echo -e 'test_dual \n' coverage run flood_forecast/trainer.py -p tests/test_dual.json + echo -e 'running dsanet \n' coverage run flood_forecast/trainer.py -p tests/dsanet.json - store_test_results: @@ -371,9 +385,9 @@ jobs: coverage run flood_forecast/trainer.py -p tests/full_transformer.json echo -e 'running da_rnn_test \n' coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' + echo -e 'running auto_encoder \n' coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' + echo -e 'running trainer_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/decoder_test.json - store_test_results: path: test-results diff --git a/docs/source/index.rst b/docs/source/index.rst index b169c3b7f..5a804229a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,8 +6,8 @@ Welcome to Flow Forecast's documentation! ========================================= -Flow Forecast is a deep learning for time series forecasting framework written in PyTorch. Flow Forecast makes it easy to train PyTorch Forecast models on a wide variety -of datasets. This documentation describes the internal Python code that makes up Flow Forecast. +Flow Forecast is a deep learning for time series forecasting framework written in PyTorch. Flow Forecast makes it easy to train deep learning models on a wide variety +of datasets. This documentation describes the internal Python code that makes up Flow Forecast as well as exposed APIs. For more detailed tutorials please go to 'Confluence '_. .. automodule:: flood_forecast diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index ac0192db9..0a8a2d440 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -29,7 +29,7 @@ def __init__( :type n_time_series: int :param forecast_history: The length of the input sequence :type forecast_history: int - :param forecast_length: The number of steps to forecast + :param forecast_length: The number of future time steps to forecast in one forward pass. :type forecast_length: int :param seg_len: Parameter specific to Crossformer, forecast_history must be divisible by seg_len :type seg_len: int @@ -37,17 +37,17 @@ def __init__( :type win_size: int, optional :param factor: _description_, defaults to 10 :type factor: int, optional - :param d_model: _description_, defaults to 512 + :param d_model: The embedding dimension of the model, defaults to 512 :type d_model: int, optional :param d_ff: _description_, defaults to 1024 :type d_ff: int, optional :param n_heads: The number of heads in the multi-head attention mechanism, defaults to 8 :type n_heads: int, optional - :param e_layers: The number of encoder layers, defaults to 3 + :param e_layers: The number of encoder layers, defaults to 3. :type e_layers: int, optional :param dropout: The amount of dropout to use when training the model, defaults to 0.0 :type dropout: float, optional - :param baseline: A boolean of whether to use mean of past time series , defaults to False + :param baseline: A boolean of whether to use mean of past time series, defaults to False :type baseline: bool, optional :param device: _description_, defaults to torch.device("cuda:0") :type device: str, optional @@ -129,6 +129,7 @@ def forward(self, x_seq: torch.Tensor): predict_y = self.decoder(dec_in, enc_out) result = base + predict_y[:, : self.out_len, :] + # Slice the tensor to only include the number of targets res = result[:, :, :self.n_targs] return res @@ -148,7 +149,7 @@ def __init__(self, d_model, win_size, norm_layer=nn.LayerNorm): self.linear_trans = nn.Linear(win_size * d_model, d_model) self.norm = norm_layer(win_size * d_model) - def forward(self, x): + def forward(self, x) -> torch.Tensor: """ x: B, ts_d, L, d_model """ diff --git a/flood_forecast/transformer_xl/data_embedding.py b/flood_forecast/transformer_xl/data_embedding.py index 4004be390..7c00bff14 100644 --- a/flood_forecast/transformer_xl/data_embedding.py +++ b/flood_forecast/transformer_xl/data_embedding.py @@ -1,6 +1,7 @@ import torch import torch.nn as nn import math +# This class contains methods to create embeddings used with models. class PositionalEmbedding(nn.Module): From 24745a7a8854ae9b7bb4de2e9341a95451db6402 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Wed, 15 May 2024 10:25:25 -0400 Subject: [PATCH 13/14] Revert "echo statements + docs" This reverts commit 19899d65bde576f458039a00fbb71ea952eab9ba. --- .circleci/config.yml | 22 ++++--------------- docs/source/index.rst | 4 ++-- flood_forecast/transformer_xl/cross_former.py | 11 +++++----- .../transformer_xl/data_embedding.py | 1 - 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b1ea5c6d..23bcc6fe7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -254,13 +254,11 @@ jobs: command: | echo -e 'GRU Vanilla test' coverage run flood_forecast/trainer.py -p tests/gru_vanilla.json - echo -e 'Running classification test' coverage run flood_forecast/trainer.py -p tests/classification_test.json - echo -e 'Running informer single test' coverage run flood_forecast/trainer.py -p tests/test_inf_single.json - echo -e 'Running transformer_gaussian test' + echo -e 'test informer single target' + echo -e 'test multi informer' coverage run flood_forecast/trainer.py -p tests/transformer_gaussian.json - echo -e 'Running multi_decoder_test.json' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json echo -e 'training multi-task-decoder' coverage run flood_forecast/trainer.py -p tests/multitask_decoder.json @@ -316,29 +314,17 @@ jobs: command: | echo -e 'running test_informer \n' coverage run flood_forecast/trainer.py -p tests/test_informer.json - echo -e 'running test_iTransformer \n' coverage run flood_forecast/trainer.py -p tests/test_iTransformer.json - echo -e 'running tsmixer_test \n' coverage run flood_forecast/trainer.py -p tests/tsmixer_test.json - echo -e 'running transformer_b_series.json \n' coverage run flood_forecast/trainer.py -p tests/transformer_b_series.json - echo -e 'running crossfroer.json \n' coverage run flood_forecast/trainer.py -p tests/cross_former.json - echo -e 'running nlinear.json \n' coverage run flood_forecast/trainer.py -p tests/nlinear.json - echo -e 'running dsanet_3\n' coverage run flood_forecast/trainer.py -p tests/dsanet_3.json - echo -e 'running variable_autoencoderl.json\n' coverage run flood_forecast/trainer.py -p tests/variable_autoencoderl.json - echo -e 'running dlinear\n' coverage run flood_forecast/trainer.py -p tests/dlinear.json - echo -e 'running custom_encode.json\n' coverage run flood_forecast/trainer.py -p tests/custom_encode.json - echo -e 'running multi_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json - echo -e 'test_dual \n' coverage run flood_forecast/trainer.py -p tests/test_dual.json - echo -e 'running dsanet \n' coverage run flood_forecast/trainer.py -p tests/dsanet.json - store_test_results: @@ -385,9 +371,9 @@ jobs: coverage run flood_forecast/trainer.py -p tests/full_transformer.json echo -e 'running da_rnn_test \n' coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto_encoder \n' + echo -e 'running auto test \n' coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' + echo -e 'running trainer_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/decoder_test.json - store_test_results: path: test-results diff --git a/docs/source/index.rst b/docs/source/index.rst index 5a804229a..b169c3b7f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,8 +6,8 @@ Welcome to Flow Forecast's documentation! ========================================= -Flow Forecast is a deep learning for time series forecasting framework written in PyTorch. Flow Forecast makes it easy to train deep learning models on a wide variety -of datasets. This documentation describes the internal Python code that makes up Flow Forecast as well as exposed APIs. For more detailed tutorials please go to 'Confluence '_. +Flow Forecast is a deep learning for time series forecasting framework written in PyTorch. Flow Forecast makes it easy to train PyTorch Forecast models on a wide variety +of datasets. This documentation describes the internal Python code that makes up Flow Forecast. .. automodule:: flood_forecast diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index 0a8a2d440..ac0192db9 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -29,7 +29,7 @@ def __init__( :type n_time_series: int :param forecast_history: The length of the input sequence :type forecast_history: int - :param forecast_length: The number of future time steps to forecast in one forward pass. + :param forecast_length: The number of steps to forecast :type forecast_length: int :param seg_len: Parameter specific to Crossformer, forecast_history must be divisible by seg_len :type seg_len: int @@ -37,17 +37,17 @@ def __init__( :type win_size: int, optional :param factor: _description_, defaults to 10 :type factor: int, optional - :param d_model: The embedding dimension of the model, defaults to 512 + :param d_model: _description_, defaults to 512 :type d_model: int, optional :param d_ff: _description_, defaults to 1024 :type d_ff: int, optional :param n_heads: The number of heads in the multi-head attention mechanism, defaults to 8 :type n_heads: int, optional - :param e_layers: The number of encoder layers, defaults to 3. + :param e_layers: The number of encoder layers, defaults to 3 :type e_layers: int, optional :param dropout: The amount of dropout to use when training the model, defaults to 0.0 :type dropout: float, optional - :param baseline: A boolean of whether to use mean of past time series, defaults to False + :param baseline: A boolean of whether to use mean of past time series , defaults to False :type baseline: bool, optional :param device: _description_, defaults to torch.device("cuda:0") :type device: str, optional @@ -129,7 +129,6 @@ def forward(self, x_seq: torch.Tensor): predict_y = self.decoder(dec_in, enc_out) result = base + predict_y[:, : self.out_len, :] - # Slice the tensor to only include the number of targets res = result[:, :, :self.n_targs] return res @@ -149,7 +148,7 @@ def __init__(self, d_model, win_size, norm_layer=nn.LayerNorm): self.linear_trans = nn.Linear(win_size * d_model, d_model) self.norm = norm_layer(win_size * d_model) - def forward(self, x) -> torch.Tensor: + def forward(self, x): """ x: B, ts_d, L, d_model """ diff --git a/flood_forecast/transformer_xl/data_embedding.py b/flood_forecast/transformer_xl/data_embedding.py index 7c00bff14..4004be390 100644 --- a/flood_forecast/transformer_xl/data_embedding.py +++ b/flood_forecast/transformer_xl/data_embedding.py @@ -1,7 +1,6 @@ import torch import torch.nn as nn import math -# This class contains methods to create embeddings used with models. class PositionalEmbedding(nn.Module): From 4829510bcdb09353357bc577bf0a4b05737c7676 Mon Sep 17 00:00:00 2001 From: isaacmg Date: Wed, 15 May 2024 10:30:08 -0400 Subject: [PATCH 14/14] fixing changes and stuff 3 --- .circleci/config.yml | 22 +++++++++++++++---- docs/source/basic_utils.rst | 4 +++- docs/source/custom_opt.rst | 2 +- docs/source/d_linear.rst | 2 +- docs/source/itransformer.rst | 2 +- .../preprocessing/pytorch_loaders.py | 5 +++-- flood_forecast/transformer_xl/basis_former.py | 1 + flood_forecast/transformer_xl/cross_former.py | 2 +- 8 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23bcc6fe7..1b1ea5c6d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -254,11 +254,13 @@ jobs: command: | echo -e 'GRU Vanilla test' coverage run flood_forecast/trainer.py -p tests/gru_vanilla.json + echo -e 'Running classification test' coverage run flood_forecast/trainer.py -p tests/classification_test.json + echo -e 'Running informer single test' coverage run flood_forecast/trainer.py -p tests/test_inf_single.json - echo -e 'test informer single target' - echo -e 'test multi informer' + echo -e 'Running transformer_gaussian test' coverage run flood_forecast/trainer.py -p tests/transformer_gaussian.json + echo -e 'Running multi_decoder_test.json' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json echo -e 'training multi-task-decoder' coverage run flood_forecast/trainer.py -p tests/multitask_decoder.json @@ -314,17 +316,29 @@ jobs: command: | echo -e 'running test_informer \n' coverage run flood_forecast/trainer.py -p tests/test_informer.json + echo -e 'running test_iTransformer \n' coverage run flood_forecast/trainer.py -p tests/test_iTransformer.json + echo -e 'running tsmixer_test \n' coverage run flood_forecast/trainer.py -p tests/tsmixer_test.json + echo -e 'running transformer_b_series.json \n' coverage run flood_forecast/trainer.py -p tests/transformer_b_series.json + echo -e 'running crossfroer.json \n' coverage run flood_forecast/trainer.py -p tests/cross_former.json + echo -e 'running nlinear.json \n' coverage run flood_forecast/trainer.py -p tests/nlinear.json + echo -e 'running dsanet_3\n' coverage run flood_forecast/trainer.py -p tests/dsanet_3.json + echo -e 'running variable_autoencoderl.json\n' coverage run flood_forecast/trainer.py -p tests/variable_autoencoderl.json + echo -e 'running dlinear\n' coverage run flood_forecast/trainer.py -p tests/dlinear.json + echo -e 'running custom_encode.json\n' coverage run flood_forecast/trainer.py -p tests/custom_encode.json + echo -e 'running multi_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/multi_decoder_test.json + echo -e 'test_dual \n' coverage run flood_forecast/trainer.py -p tests/test_dual.json + echo -e 'running dsanet \n' coverage run flood_forecast/trainer.py -p tests/dsanet.json - store_test_results: @@ -371,9 +385,9 @@ jobs: coverage run flood_forecast/trainer.py -p tests/full_transformer.json echo -e 'running da_rnn_test \n' coverage run flood_forecast/trainer.py -p tests/da_rnn.json - echo -e 'running auto test \n' + echo -e 'running auto_encoder \n' coverage run flood_forecast/meta_train.py -p tests/auto_encoder.json - echo -e 'running trainer_decoder_test \n' + echo -e 'running trainer_decoder_test \n' coverage run flood_forecast/trainer.py -p tests/decoder_test.json - store_test_results: path: test-results diff --git a/docs/source/basic_utils.rst b/docs/source/basic_utils.rst index ebf404532..965427353 100644 --- a/docs/source/basic_utils.rst +++ b/docs/source/basic_utils.rst @@ -1,5 +1,7 @@ -Basic GCP Utils +Basic Google Cloud Platform Utilities ================ +Flow Forecast natively integrates with Google Cloud Platform. + .. automodule:: flood_forecast.gcp_integration.basic_utils :members: diff --git a/docs/source/custom_opt.rst b/docs/source/custom_opt.rst index dd7008614..b8d561c53 100644 --- a/docs/source/custom_opt.rst +++ b/docs/source/custom_opt.rst @@ -1,4 +1,4 @@ -Custom Optimizations +Custom Optimizers and more ==================== .. automodule:: flood_forecast.custom.custom_opt diff --git a/docs/source/d_linear.rst b/docs/source/d_linear.rst index c2368ff4c..c3a1450dd 100644 --- a/docs/source/d_linear.rst +++ b/docs/source/d_linear.rst @@ -1,4 +1,4 @@ -D and N LInear +D and N Linear ================== .. automodule:: flood_forecast.basic.d_n_linear diff --git a/docs/source/itransformer.rst b/docs/source/itransformer.rst index d049dd2f3..774085f28 100644 --- a/docs/source/itransformer.rst +++ b/docs/source/itransformer.rst @@ -1,4 +1,4 @@ -I-Transformer Model +I-Transformer Model. ================== .. automodule:: flood_forecast.transformer_xl.itransformer diff --git a/flood_forecast/preprocessing/pytorch_loaders.py b/flood_forecast/preprocessing/pytorch_loaders.py index 55b9879d5..fa061dc28 100644 --- a/flood_forecast/preprocessing/pytorch_loaders.py +++ b/flood_forecast/preprocessing/pytorch_loaders.py @@ -197,7 +197,8 @@ def __init__(self, series_id_col: str, main_params: dict, return_method: str, re print(new_df.columns) self.listed_vals = df_list self.__make_unique_dict__() - self.__validate_data__in_df() + if return_all: + self.__validate_data__in_df() print(self.unique_dict) print("unique dict") @@ -665,7 +666,7 @@ def __init__(self, series_id_col: str, main_params: dict, return_method: str, fo :type series_id_col: str :param main_params: The core params used to instantiate the CSVSeriesIDLoader :type main_params: dict - :param return_method: What method to return to. + :param return_method: The method of return :type return_method: str :param return_all: _description_, defaults to True :type return_all: bool, optional diff --git a/flood_forecast/transformer_xl/basis_former.py b/flood_forecast/transformer_xl/basis_former.py index e69de29bb..f17ccf3a4 100644 --- a/flood_forecast/transformer_xl/basis_former.py +++ b/flood_forecast/transformer_xl/basis_former.py @@ -0,0 +1 @@ +# TO-DO implement basis former \ No newline at end of file diff --git a/flood_forecast/transformer_xl/cross_former.py b/flood_forecast/transformer_xl/cross_former.py index ac0192db9..57c57cae1 100644 --- a/flood_forecast/transformer_xl/cross_former.py +++ b/flood_forecast/transformer_xl/cross_former.py @@ -47,7 +47,7 @@ def __init__( :type e_layers: int, optional :param dropout: The amount of dropout to use when training the model, defaults to 0.0 :type dropout: float, optional - :param baseline: A boolean of whether to use mean of past time series , defaults to False + :param baseline: A boolean of whether to use mean of the past time series , defaults to False :type baseline: bool, optional :param device: _description_, defaults to torch.device("cuda:0") :type device: str, optional