batch_first

This commit is contained in:
Dr. Kashif Rasul
2019-12-19 21:34:17 +01:00
parent e7651a510a
commit bb701476f2
+5 -5
View File
@@ -237,7 +237,7 @@ class CanonicalInstanceSplitter(FlatMapTransformation):
instance sampler that provides sampling indices given a time-series
instance_length
length of the target seen before making prediction
output_NTC
batch_first
whether to have time series output in (time, dimension) or in
(dimension, time) layout
time_series_fields
@@ -262,7 +262,7 @@ class CanonicalInstanceSplitter(FlatMapTransformation):
forecast_start_field: str,
instance_sampler: InstanceSampler,
instance_length: int,
output_NTC: bool = True,
batch_first: bool = True,
time_series_fields: List[str] = [],
allow_target_padding: bool = False,
pad_value: float = 0.0,
@@ -271,7 +271,7 @@ class CanonicalInstanceSplitter(FlatMapTransformation):
) -> None:
self.instance_sampler = instance_sampler
self.instance_length = instance_length
self.output_NTC = output_NTC
self.batch_first = batch_first
self.dynamic_feature_fields = time_series_fields
self.target_field = target_field
self.allow_target_padding = allow_target_padding
@@ -341,14 +341,14 @@ class CanonicalInstanceSplitter(FlatMapTransformation):
else:
past_ts = full_ts[..., (i - self.instance_length) : i]
past_ts = past_ts.transpose() if self.output_NTC else past_ts
past_ts = past_ts.transpose() if self.batch_first else past_ts
d[self._past(ts_field)] = past_ts
if self.use_prediction_features and not is_train:
if not ts_field == self.target_field:
future_ts = full_ts[..., i : i + self.prediction_length]
future_ts = (
future_ts.transpose() if self.output_NTC else future_ts
future_ts.transpose() if self.batch_first else future_ts
)
d[self._future(ts_field)] = future_ts