mirror of
https://github.com/wassname/pytorch-ts.git
synced 2026-08-11 11:24:31 +08:00
typos
This commit is contained in:
@@ -1 +1 @@
|
||||
from .loader import TransformedIterableDataset
|
||||
from .loader import TransformedIterableDataset
|
||||
|
||||
@@ -1 +1 @@
|
||||
from .datasets import dataset_recipes
|
||||
from .datasets import dataset_recipes
|
||||
|
||||
@@ -47,6 +47,7 @@ class FourierDateFeatures(TimeFeature):
|
||||
steps = [x * 2.0 * np.pi / num_values for x in values]
|
||||
return np.vstack([np.cos(steps), np.sin(steps)])
|
||||
|
||||
|
||||
def fourier_time_features_from_frequency(freq_str: str) -> List[TimeFeature]:
|
||||
offset = to_offset(freq_str)
|
||||
multiple, granularity = offset.n, offset.name
|
||||
@@ -66,4 +67,4 @@ def fourier_time_features_from_frequency(freq_str: str) -> List[TimeFeature]:
|
||||
feature_classes: List[TimeFeature] = [
|
||||
FourierDateFeatures(freq=freq) for freq in features[granularity]
|
||||
]
|
||||
return feature_classes
|
||||
return feature_classes
|
||||
|
||||
@@ -32,7 +32,7 @@ from pts import Trainer
|
||||
from pts.model.utils import get_module_forward_input_names
|
||||
from pts.feature import (
|
||||
fourier_time_features_from_frequency,
|
||||
lags_for_fourier_time_features_from_frequency
|
||||
lags_for_fourier_time_features_from_frequency,
|
||||
)
|
||||
from pts.model import PyTorchEstimator
|
||||
from pts.modules import LowRankMultivariateNormalOutput
|
||||
|
||||
@@ -26,7 +26,7 @@ from gluonts.transform import (
|
||||
from pts import Trainer
|
||||
from pts.feature import (
|
||||
fourier_time_features_from_frequency,
|
||||
lags_for_fourier_time_features_from_frequency
|
||||
lags_for_fourier_time_features_from_frequency,
|
||||
)
|
||||
from pts.model.utils import get_module_forward_input_names
|
||||
from pts.model import PyTorchEstimator
|
||||
|
||||
@@ -10,7 +10,7 @@ from gluonts.torch.modules.distribution_output import DistributionOutput
|
||||
from gluonts.torch.support.util import copy_parameters
|
||||
from gluonts.torch.model.predictor import PyTorchPredictor
|
||||
from gluonts.model.predictor import Predictor
|
||||
from gluonts.transform import (
|
||||
from gluonts.transform import (
|
||||
Transformation,
|
||||
Chain,
|
||||
InstanceSplitter,
|
||||
@@ -205,7 +205,7 @@ class TransformerEstimator(PyTorchEstimator):
|
||||
def create_predictor(
|
||||
self,
|
||||
transformation: Transformation,
|
||||
trained_network:TransformerTrainingNetwork,
|
||||
trained_network: TransformerTrainingNetwork,
|
||||
device: torch.device,
|
||||
) -> Predictor:
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ from typing import List, Optional, Tuple
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
|
||||
from gluonts.core.component import
|
||||
|
||||
from gluonts.core.component import validated
|
||||
from pts.modules import RealNVP, MAF, FlowOutput, MeanScaler, NOPScaler
|
||||
|
||||
|
||||
|
||||
+6
-2
@@ -35,7 +35,11 @@ def weighted_average(
|
||||
"""
|
||||
if weights is not None:
|
||||
weighted_tensor = torch.where(weights != 0, x * weights, torch.zeros_like(x))
|
||||
sum_weights = torch.clamp(weights.sum(dim=dim) if dim else weights.sum(), min=1.0)
|
||||
return (weighted_tensor.sum(dim=dim) if dim else weighted_tensor.sum())/ sum_weights
|
||||
sum_weights = torch.clamp(
|
||||
weights.sum(dim=dim) if dim else weights.sum(), min=1.0
|
||||
)
|
||||
return (
|
||||
weighted_tensor.sum(dim=dim) if dim else weighted_tensor.sum()
|
||||
) / sum_weights
|
||||
else:
|
||||
return x.mean(dim=dim)
|
||||
|
||||
Reference in New Issue
Block a user