-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor DirectPred class: add 2 methods for layer creation * Add Simple CNN implementation * Duplicate example notebook * Final fixes * Update example notebook and config file
- Loading branch information
Showing
10 changed files
with
2,887 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .direct_pred import DirectPred | ||
from .direct_pred_cnn import DirectPredCNN | ||
from .supervised_vae import SupervisedVAE | ||
from .triplet_encoder import MultiTripletNetwork | ||
|
||
__all__ = ["DirectPred", "SupervisedVAE", "MultiTripletNetwork"] | ||
__all__ = ["DirectPred", "DirectPredCNN", "SupervisedVAE", "MultiTripletNetwork"] |
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,29 @@ | ||
import numpy as np | ||
from torch import nn | ||
|
||
from .direct_pred import DirectPred | ||
from ..modules import CNN | ||
|
||
|
||
class DirectPredCNN(DirectPred): | ||
def _init_encoders(self): | ||
layers = list(self.dataset.dat.keys()) | ||
input_dims = [len(self.dataset.features[layers[i]]) for i in range(len(layers))] | ||
self.encoders = nn.ModuleList([ | ||
CNN(input_dim=input_dims[i], hidden_dim=self.config["hidden_dim"], output_dim=self.config["latent_dim"]) | ||
for i in range(len(layers)) | ||
]) | ||
|
||
def _init_output_layers(self): | ||
layers = list(self.dataset.dat.keys()) | ||
self.MLPs = nn.ModuleDict() | ||
for var in self.target_variables: | ||
if self.dataset.variable_types[var] == "numerical": | ||
num_class = 1 | ||
else: | ||
num_class = len(np.unique(self.dataset.ann[var])) | ||
self.MLPs[var] = CNN( | ||
input_dim=self.config["latent_dim"] * len(layers), | ||
hidden_dim=self.config["hidden_dim"], | ||
output_dim=num_class, | ||
) |
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