-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch dev into branch (refactor)random_walk
- Loading branch information
Showing
189 changed files
with
4,146 additions
and
2,267 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
repos: | ||
# hooks for checking files | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
rev: v4.6.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
|
||
# hooks for linting code | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
rev: 24.8.0 | ||
hooks: | ||
- id: black | ||
args: [ | ||
--line-length=120, # refer to pyproject.toml | ||
] | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 6.0.0 | ||
rev: 7.1.1 | ||
hooks: | ||
- id: flake8 | ||
args: [ | ||
--max-line-length=120, # refer to pyproject.toml | ||
--extend-ignore=E203, # why ignore E203? Refer to https://github.com/PyCQA/pycodestyle/issues/373 | ||
--extend-ignore=E203,E231 | ||
] |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
and takes over the forward progress of the algorithm. | ||
""" | ||
|
||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: BSD-3-Clause | ||
|
||
|
@@ -84,21 +83,13 @@ def forward(self, inputs, training=True): | |
lengths2 = lengths.unsqueeze(1).to(device) | ||
mask2 = mask.permute(1, 0).unsqueeze(2).long() | ||
if self.sensor_wise_mask: | ||
output = torch.zeros( | ||
[batch_size, self.n_features, self.d_ob + 16], device=device | ||
) | ||
output = torch.zeros([batch_size, self.n_features, self.d_ob + 16], device=device) | ||
extended_missing_mask = missing_mask.view(-1, batch_size, self.n_features) | ||
for se in range(self.n_features): | ||
representation = representation.view( | ||
-1, batch_size, self.n_features, (self.d_ob + 16) | ||
) | ||
representation = representation.view(-1, batch_size, self.n_features, (self.d_ob + 16)) | ||
out = representation[:, :, se, :] | ||
l_ = torch.sum(extended_missing_mask[:, :, se], dim=0).unsqueeze( | ||
1 | ||
) # length | ||
out_sensor = torch.sum( | ||
out * (1 - extended_missing_mask[:, :, se].unsqueeze(-1)), dim=0 | ||
) / (l_ + 1) | ||
l_ = torch.sum(extended_missing_mask[:, :, se], dim=0).unsqueeze(1) # length | ||
out_sensor = torch.sum(out * (1 - extended_missing_mask[:, :, se].unsqueeze(-1)), dim=0) / (l_ + 1) | ||
output[:, se, :] = out_sensor | ||
output = output.view([-1, self.n_features * (self.d_ob + 16)]) | ||
elif self.aggregation == "mean": | ||
|
@@ -116,9 +107,7 @@ def forward(self, inputs, training=True): | |
|
||
# if in training mode, return results with losses | ||
if training: | ||
classification_loss = F.nll_loss( | ||
torch.log(classification_pred), inputs["label"] | ||
) | ||
classification_loss = F.nll_loss(torch.log(classification_pred), inputs["label"]) | ||
results["loss"] = classification_loss | ||
|
||
return results |
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
""" | ||
|
||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: BSD-3-Clause | ||
|
||
|
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
Oops, something went wrong.