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

Multimodal models #816

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 104 additions & 106 deletions .circleci/config.yml

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
sphinx
sphinx-rtd-theme
sphinx-autodoc-typehints
shap==0.46.0
scikit-learn>=1.0.1
pandas
numpy
torch
matplotlib
plotly
tb-nightly
seaborn
future
h5py
wandb==0.17.2
google-cloud
google-cloud-storage
scikit-learn
wandb
shap
plotly~=5.24.0
pytz>=2022.1
setuptools~=69.5.1
numpy==1.26
requests
torchvision>=0.6.0
mpld3>=0.5
numba>=0.50
sphinx
sphinx-rtd-theme
sphinx-autodoc-typehints
sphinx
einops
pytorch-tsmixer
einsum
jaxtyping
4 changes: 2 additions & 2 deletions docs/source/basic_ae.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Simple AE
==============
Simple Auto Encoder
==================

.. automodule:: flood_forecast.meta_models.basic_ae
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/basic_utils.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Basic Google Cloud Platform Utilities
=====================================
======================================

Flow Forecast natively integrates with Google Cloud Platform.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/custom_opt.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Custom Optimizers and more
==========================
Custom Optimizers
====================

.. automodule:: flood_forecast.custom.custom_opt
:members:
8 changes: 4 additions & 4 deletions flood_forecast/basic/base_line_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def __init__(self, seq_length: int, n_time_series: int, output_seq_len=1, metric
self.metric_function = self.metric_dict[metric]

def forward(self, x: torch.Tensor) -> torch.Tensor:
"""_summary_
"""The forward pass of the NaiveModel

Args:
x (torch.Tensor): _description_
param x: The input tensor of shape (batch_size, seq_len, n_time_series)
type x: torch.Tensor

Returns:
torch.Tensor: _description_
torch.Tensor: The output tensor of shape (batch_size, output_seq_len, 1)
"""
return self.metric_function(x, self.output_seq_len)

Expand Down
6 changes: 3 additions & 3 deletions flood_forecast/basic/d_n_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class NLinear(nn.Module):
"""Normalization-Linear."""
"""Normalization of Linear fixing."""

def __init__(self, forecast_history: int, forecast_length: int, enc_in=128, individual=False, n_targs=1):
super(NLinear, self).__init__()
Expand Down Expand Up @@ -113,11 +113,11 @@ def __init__(self, forecast_history: int, forecast_length: int, individual, enc_
# self.Linear_Trend.weight = nn.Parameter((1/self.seq_len)*torch.ones([self.pred_len2,self.seq_len]))

def forward(self, x: torch.Tensor):
"""The.
"""The forward pass of the D-Linear model.

:param x: PyTorch tensor of size [Batch, Input length, Channel]
:type x: _type_
:return: _description_
:return: Returns the output tensor of size [Batch, Output length, Channel]
:rtype: _type_
"""
seasonal_init, trend_init = self.decompsition(x)
Expand Down
4 changes: 2 additions & 2 deletions flood_forecast/basic/gru_vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def __init__(self, n_time_series: int, hidden_dim: int, num_layers: int, n_targe

:param n_time_series: The number of time series present in the data
:type n_time_series int:
:param hidden_dim:
:param hidden_dim: The hidden dimension of the GRU.
:type hidden_dim:

Note for probablistic n_targets must be set to two and actual multiple targs are not supported now.
Note for probabilistic n_targets must be set to two and actual multiple targets are not supported now.
"""
super(VanillaGRU, self).__init__()

Expand Down
8 changes: 5 additions & 3 deletions flood_forecast/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
def stream_baseline(
river_flow_df: pd.DataFrame, forecast_column: str, hours_forecast=336
) -> Tuple[pd.DataFrame, float]:
"""Function to compute the baseline MSE by using the mean value from the train data."""
"""Function to compute the baseline MSE by using the mean value from the train data.
"""
total_length = len(river_flow_df.index)
train_river_data = river_flow_df[: total_length - hours_forecast]
test_river_data = river_flow_df[total_length - hours_forecast:]
Expand Down Expand Up @@ -162,8 +163,9 @@ def evaluate_model(
return eval_log, df_train_and_test, forecast_start_idx, df_predictions


def run_evaluation(model, df_train_and_test, forecast_history, target_col, end_tensor, g_loss=False, eval_log={},
end_tensor_0=None) -> Dict:
def run_evaluation(model, df_train_and_test: pd.DataFrame, forecast_history, target_col: str, end_tensor, g_loss=False,
eval_log: Dict = {}, end_tensor_0=None) -> Dict:
"""Function to run evaluation on the model."""
inference_params = model.params["inference_params"]
for evaluation_metric in model.crit:
idx = 0
Expand Down
2 changes: 1 addition & 1 deletion flood_forecast/explain_model_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def handle_dl_output(dl, dl_class: str, datetime_start: datetime, device: str) -> Tuple[torch.Tensor, int]:
"""
:param dl: The test data-loader. Should be passed directly
:param dl: The test data-loader. Should be passed directly.
:type dl: Union[CSVTestLoader, TemporalTestLoader]
:param dl_class: A string that is the name of DL passef from the params file
:type dl_class: str
Expand Down
Loading
Loading