-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from WenjieDu/dev
Fix failed docs building, update the docs, and allow tests for CLI to fail
- Loading branch information
Showing
35 changed files
with
115 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
PyTorch BRITS model for both the time-series imputation task and the classification task. | ||
""" | ||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: GPL-v3 | ||
|
||
from typing import Union | ||
|
||
import torch | ||
import torch.nn as nn | ||
|
||
from pypots.imputation.brits.model import ( | ||
RITS as imputation_RITS, | ||
) | ||
|
||
|
||
class RITS(imputation_RITS): | ||
def __init__( | ||
self, | ||
n_steps: int, | ||
n_features: int, | ||
rnn_hidden_size: int, | ||
n_classes: int, | ||
device: Union[str, torch.device], | ||
): | ||
super().__init__(n_steps, n_features, rnn_hidden_size, device) | ||
self.dropout = nn.Dropout(p=0.25) | ||
self.classifier = nn.Linear(self.rnn_hidden_size, n_classes) | ||
|
||
def forward(self, inputs: dict, direction: str = "forward") -> dict: | ||
ret_dict = super().forward(inputs, direction) | ||
logits = self.classifier(ret_dict["final_hidden_state"]) | ||
ret_dict["prediction"] = torch.softmax(logits, dim=1) | ||
return ret_dict |
Oops, something went wrong.