dont set scale if scaling is false

This commit is contained in:
Dr. Kashif Rasul
2020-01-15 15:24:11 +01:00
parent c1970eae9b
commit 6ee817ab72
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -37,6 +37,7 @@ class TempFlowTrainingNetwork(nn.Module):
self.prediction_length = prediction_length
self.context_length = context_length
self.history_length = history_length
self.scaling = scaling
assert len(set(lags_seq)) == len(lags_seq), "no duplicated lags allowed!"
lags_seq.sort()
@@ -379,7 +380,8 @@ class TempFlowTrainingNetwork(nn.Module):
# assert_shape(target, (-1, seq_len, self.target_dim))
distr_args = self.distr_args(rnn_outputs=rnn_outputs)
self.flow.scale = scale
if self.scaling:
self.flow.scale = scale
# we sum the last axis to have the same shape for all likelihoods
# (batch_size, subseq_length, 1)
@@ -495,7 +497,8 @@ class TempFlowPredictionNetwork(TempFlowTrainingNetwork):
)
distr_args = self.distr_args(rnn_outputs=rnn_outputs,)
self.flow.scale = repeated_scale
if self.scaling:
self.flow.scale = repeated_scale
# (batch_size, 1, target_dim)
new_samples = self.flow.sample(cond=distr_args)
+1 -1
View File
@@ -186,7 +186,7 @@ class RealNVP(nn.Module):
def sample(self, sample_shape=torch.Size(), cond=None):
if cond is not None:
shape = cond.shape[:-1]
shape = cond.shape[:-1]
else:
shape = sample_shape