Skip to content

Commit

Permalink
improve decoding function; decode all output layers; convert to data …
Browse files Browse the repository at this point in the history
…frame and add row/col names
  • Loading branch information
borauyar committed Apr 3, 2024
1 parent 357fada commit 221961b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions flexynesis/models/crossmodal_pred.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def __init__(self, config, dataset, target_variables = None, batch_variables =
[int(output_dims[i] * config['hidden_dim_factor'])],
output_dims[i])
for i in range(len(self.output_layers))])
print(self.decoders)

# define supervisor heads
# using ModuleDict to store multiple MLPs
Expand Down Expand Up @@ -342,11 +341,18 @@ def decode(self, dataset):
"""
Extract the decoded values of the target/output layers
"""

self.eval()
x_list = [dataset.dat[x] for x in self.input_layers]
X_hat, z, mean, log_var, outputs = self.forward(x_list)
return X_hat
x_list_input = [dataset.dat[x] for x in self.input_layers]
x_list_output = [dataset.dat[x] for x in self.output_layers]
x_hat_list, z, mean, log_var, outputs = self.forward(x_list_input, x_list_output)
X = {}
for i in range(len(self.output_layers)):
x = pd.DataFrame(x_hat_list[i].detach().numpy()).transpose()
layer = self.output_layers[i]
x.columns = dataset.samples
x.index = dataset.features[layer]
X[layer] = x
return X


def compute_kernel(self, x, y):
Expand Down

0 comments on commit 221961b

Please sign in to comment.