[ { "function_name": "Exp_Main.__init__", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "super().__init__", "functionality": "Initializes the parent class 'Exp_Basic' to set up the basic experiment environment, including model, device, and arguments.", "input": "args", "output": "None", "location_or_namespace": "exp/exp_basic.py" }, { "function_call_name": "nn.KLDivLoss", "functionality": "Creates a criterion that measures the Kullback-Leibler divergence. It is used for the variance component of the PS Loss.", "input": "reduction='none'", "output": "A callable KLDivLoss object.", "location_or_namespace": "torch.nn" } ] }, { "function_name": "Exp_Main._build_model", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "Model", "functionality": "Initializes a time series forecasting model (e.g., DLinear, Autoformer) based on the provided arguments.", "input": "self.args", "output": "A PyTorch model object.", "location_or_namespace": "models" }, { "function_call_name": "float", "functionality": "Casts the model's parameters and buffers to float data type.", "input": "None", "output": "The model with float data type parameters.", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "nn.DataParallel", "functionality": "Implements data parallelism at the module level to use multiple GPUs.", "input": "model, device_ids=self.args.device_ids", "output": "A DataParallel wrapper around the model.", "location_or_namespace": "torch.nn" } ] }, { "function_name": "Exp_Main._get_data", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "data_provider", "functionality": "Factory function to create a dataset and data loader based on the specified arguments and data flag ('train', 'val', or 'test').", "input": "self.args, flag", "output": "A tuple containing the dataset and data loader.", "location_or_namespace": "data_provider/data_factory.py" } ] }, { "function_name": "Exp_Main._select_optimizer", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "optim.Adam", "functionality": "Initializes the Adam optimizer with the model's parameters and a specified learning rate.", "input": "self.model.parameters(), lr=self.args.learning_rate", "output": "An Adam optimizer object.", "location_or_namespace": "torch.optim" } ] }, { "function_name": "Exp_Main._select_criterion", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "nn.MSELoss", "functionality": "Creates a criterion that measures the mean-squared error between each element in the input and target.", "input": "None", "output": "An MSELoss object.", "location_or_namespace": "torch.nn" } ] }, { "function_name": "Exp_Main.create_patches", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "permute", "functionality": "Returns a view of the original tensor with its dimensions permuted.", "input": "0, 2, 1", "output": "A view of the tensor with permuted dimensions.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "unfold", "functionality": "Returns a view of the original tensor which contains all slices of size `patch_len` from the specified dimension.", "input": "2, patch_len, stride", "output": "A view of the tensor containing all slices.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "reshape", "functionality": "Returns a tensor with the same data and number of elements as the input, but with the specified shape.", "input": "B, C, num_patches, patch_len", "output": "A reshaped tensor.", "location_or_namespace": "torch.Tensor" } ] }, { "function_name": "Exp_Main.fouriour_based_adaptive_patching", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "torch.fft.rfft", "functionality": "Computes the one-dimensional discrete Fourier Transform for real input.", "input": "true, dim=1", "output": "The Fourier-transformed tensor.", "location_or_namespace": "torch.fft" }, { "function_call_name": "torch.abs", "functionality": "Computes the absolute value of each element in the input tensor.", "input": "true_fft", "output": "A tensor with absolute values.", "location_or_namespace": "torch" }, { "function_call_name": "mean", "functionality": "Computes the mean of all elements in the tensor along specified dimensions.", "input": "0, -1", "output": "A tensor with the mean values.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "torch.argmax", "functionality": "Returns the indices of the maximum value of all elements in the input tensor.", "input": "frequency_list", "output": "A tensor with the index of the maximum value.", "location_or_namespace": "torch" }, { "function_call_name": "min", "functionality": "Returns the smallest of its arguments.", "input": "period // 2, self.patch_len_threshold", "output": "The minimum value.", "location_or_namespace": "built-in" }, { "function_call_name": "self.create_patches", "functionality": "Segments a time series tensor into overlapping patches.", "input": "true, patch_len, stride=stride", "output": "A tensor of patches.", "location_or_namespace": "exp/exp_main.py" } ] }, { "function_name": "Exp_Main.patch_wise_structural_loss", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "torch.mean", "functionality": "Computes the mean value of all elements in the input tensor.", "input": "tensor, dim=-1, keepdim=True", "output": "A tensor containing the mean value.", "location_or_namespace": "torch" }, { "function_call_name": "torch.var", "functionality": "Computes the variance of all elements in the input tensor.", "input": "tensor, dim=-1, keepdim=True, unbiased=False", "output": "A tensor containing the variance.", "location_or_namespace": "torch" }, { "function_call_name": "torch.sqrt", "functionality": "Computes the square-root of each element in the input tensor.", "input": "variance_tensor", "output": "A tensor containing the standard deviation.", "location_or_namespace": "torch" }, { "function_call_name": "torch.softmax", "functionality": "Applies the Softmax function to an n-dimensional input Tensor rescaling them so that the elements of the n-dimensional output Tensor lie in the range [0,1] and sum to 1.", "input": "true_patch, dim=-1", "output": "A tensor with softmax-normalized values.", "location_or_namespace": "torch" }, { "function_call_name": "torch.log_softmax", "functionality": "Applies a softmax followed by a logarithm.", "input": "pred_patch, dim=-1", "output": "A tensor with log-softmax-normalized values.", "location_or_namespace": "torch" }, { "function_call_name": "self.kl_loss", "functionality": "Computes the Kullback-Leibler divergence loss between two distributions.", "input": "pred_patch_softmax, true_patch_softmax", "output": "A tensor containing the KL divergence loss.", "location_or_namespace": "torch.nn.KLDivLoss" }, { "function_call_name": "torch.abs", "functionality": "Computes the absolute value of each element in the input tensor.", "input": "true_patch_mean - pred_patch_mean", "output": "A tensor containing absolute differences.", "location_or_namespace": "torch" } ] }, { "function_name": "Exp_Main.ps_loss", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "self.fouriour_based_adaptive_patching", "functionality": "Determines patch length from the dominant frequency of the ground truth series and segments both series into patches.", "input": "true, pred", "output": "A tuple of patched ground truth and prediction tensors.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "self.patch_wise_structural_loss", "functionality": "Calculates the three components of the Patch-wise Structural loss: correlation, variance, and mean.", "input": "true_patch, pred_patch", "output": "A tuple containing the correlation, variance, and mean losses.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "self.gradient_based_dynamic_weighting", "functionality": "Implements the Gradient-based Dynamic Weighting (GDW) strategy to balance the three loss components.", "input": "true, pred, corr_loss, var_loss, mean_loss", "output": "A tuple of weights (alpha, beta, gamma).", "location_or_namespace": "exp/exp_main.py" } ] }, { "function_name": "Exp_Main.gradient_based_dynamic_weighting", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "permute", "functionality": "Returns a view of the original tensor with its dimensions permuted.", "input": "0, 2, 1", "output": "A view of the tensor with permuted dimensions.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "torch.mean", "functionality": "Computes the mean value of all elements in the input tensor.", "input": "tensor, dim=-1, keepdim=True", "output": "A tensor containing the mean value.", "location_or_namespace": "torch" }, { "function_call_name": "torch.var", "functionality": "Computes the variance of all elements in the input tensor.", "input": "tensor, dim=-1, keepdim=True, unbiased=False", "output": "A tensor containing the variance.", "location_or_namespace": "torch" }, { "function_call_name": "torch.sqrt", "functionality": "Computes the square-root of each element in the input tensor.", "input": "variance_tensor", "output": "A tensor containing the standard deviation.", "location_or_namespace": "torch" }, { "function_call_name": "torch.autograd.grad", "functionality": "Computes and returns the sum of gradients of outputs with respect to the inputs.", "input": "loss, self.model.Linear_Trend.parameters(), create_graph=True", "output": "A tuple of gradients.", "location_or_namespace": "torch.autograd" }, { "function_call_name": "norm", "functionality": "Returns the L2-norm of the tensor.", "input": "None", "output": "A scalar tensor representing the norm.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "detach", "functionality": "Returns a new tensor, detached from the current graph. The result will never require gradient.", "input": "None", "output": "A detached tensor.", "location_or_namespace": "torch.Tensor" } ] }, { "function_name": "Exp_Main.vali", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "self.model.eval", "functionality": "Sets the model to evaluation mode.", "input": "None", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "enumerate", "functionality": "Returns an enumerate object, which yields pairs containing a count and a value from the iterable.", "input": "vali_loader", "output": "An iterator of (index, batch) tuples.", "location_or_namespace": "built-in" }, { "function_call_name": "torch.zeros_like", "functionality": "Returns a tensor filled with the scalar value 0, with the same size as input.", "input": "batch_y[:, -self.args.pred_len:, :]", "output": "A tensor of zeros.", "location_or_namespace": "torch" }, { "function_call_name": "torch.cat", "functionality": "Concatenates the given sequence of tensors in the given dimension.", "input": "[batch_y[:, :self.args.label_len, :], dec_inp], dim=1", "output": "A concatenated tensor.", "location_or_namespace": "torch" }, { "function_call_name": "self.model", "functionality": "Performs a forward pass of the model to generate predictions.", "input": "batch_x, batch_x_mark, dec_inp, batch_y_mark", "output": "The model's output tensor.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "criterion", "functionality": "Computes the loss between the predictions and the ground truth.", "input": "pred, true", "output": "A scalar tensor representing the loss.", "location_or_namespace": "torch.nn" }, { "function_call_name": "np.average", "functionality": "Computes the weighted average along the specified axis.", "input": "total_loss", "output": "The average loss.", "location_or_namespace": "numpy" }, { "function_call_name": "self.model.train", "functionality": "Sets the model to training mode.", "input": "None", "output": "None", "location_or_namespace": "torch.nn.Module" } ] }, { "function_name": "Exp_Main.train", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "self._get_data", "functionality": "Gets the dataset and data loader for a specified flag ('train', 'val', or 'test').", "input": "flag='train'", "output": "A tuple of dataset and data loader.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "os.path.join", "functionality": "Joins one or more path components intelligently.", "input": "self.args.checkpoints, setting", "output": "A string representing the full path.", "location_or_namespace": "os.path" }, { "function_call_name": "os.makedirs", "functionality": "Recursive directory creation function.", "input": "path", "output": "None", "location_or_namespace": "os" }, { "function_call_name": "time.time", "functionality": "Returns the time in seconds since the epoch as a floating point number.", "input": "None", "output": "The current time as a float.", "location_or_namespace": "time" }, { "function_call_name": "EarlyStopping", "functionality": "Initializes an early stopping handler to monitor validation loss and stop training if it doesn't improve.", "input": "patience=self.args.patience, verbose=True", "output": "An EarlyStopping object.", "location_or_namespace": "utils/tools.py" }, { "function_call_name": "self._select_optimizer", "functionality": "Selects and initializes the optimizer for training.", "input": "None", "output": "An optimizer object.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "self._select_criterion", "functionality": "Selects and initializes the primary loss function.", "input": "None", "output": "A criterion object.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "torch.cuda.amp.GradScaler", "functionality": "Creates a gradient scaler for automatic mixed-precision training.", "input": "None", "output": "A GradScaler object.", "location_or_namespace": "torch.cuda.amp" }, { "function_call_name": "self.model.train", "functionality": "Sets the model to training mode.", "input": "None", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "enumerate", "functionality": "Returns an enumerate object, which yields pairs containing a count and a value from the iterable.", "input": "train_loader", "output": "An iterator of (index, batch) tuples.", "location_or_namespace": "built-in" }, { "function_call_name": "model_optim.zero_grad", "functionality": "Sets the gradients of all optimized tensors to zero.", "input": "None", "output": "None", "location_or_namespace": "torch.optim.Optimizer" }, { "function_call_name": "torch.cat", "functionality": "Concatenates the given sequence of tensors in the given dimension.", "input": "[batch_y[:, :self.args.label_len, :], dec_inp], dim=1", "output": "A concatenated tensor.", "location_or_namespace": "torch" }, { "function_call_name": "self.model", "functionality": "Performs a forward pass of the model to generate predictions.", "input": "batch_x, batch_x_mark, dec_inp, batch_y_mark, batch_y", "output": "The model's output tensor.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "criterion", "functionality": "Computes the primary loss between predictions and ground truth.", "input": "outputs, batch_y", "output": "A scalar tensor representing the loss.", "location_or_namespace": "torch.nn" }, { "function_call_name": "self.ps_loss", "functionality": "Computes the total Patch-wise Structural loss.", "input": "batch_y, outputs", "output": "A scalar tensor representing the PS loss.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "loss.backward", "functionality": "Computes the gradient of the loss with respect to graph leaves.", "input": "None", "output": "None", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "model_optim.step", "functionality": "Performs a single optimization step (parameter update).", "input": "None", "output": "None", "location_or_namespace": "torch.optim.Optimizer" }, { "function_call_name": "np.average", "functionality": "Compute the weighted average along the specified axis.", "input": "train_loss", "output": "The average loss.", "location_or_namespace": "numpy" }, { "function_call_name": "self.vali", "functionality": "Evaluates the model on the validation dataset.", "input": "vali_data, vali_loader, criterion", "output": "The average validation loss.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "early_stopping", "functionality": "Checks the validation loss and determines if training should stop early.", "input": "vali_loss, self.model, path", "output": "None", "location_or_namespace": "utils/tools.py" }, { "function_call_name": "adjust_learning_rate", "functionality": "Adjusts the learning rate of the optimizer based on the current epoch.", "input": "model_optim, epoch + 1, self.args", "output": "None", "location_or_namespace": "utils/tools.py" }, { "function_call_name": "torch.load", "functionality": "Loads an object saved with torch.save() from a file.", "input": "best_model_path, map_location='cuda:0'", "output": "The loaded object, typically a state dictionary.", "location_or_namespace": "torch" }, { "function_call_name": "self.model.load_state_dict", "functionality": "Loads a model's parameter dictionary.", "input": "torch.load(best_model_path, map_location='cuda:0')", "output": "None", "location_or_namespace": "torch.nn.Module" } ] }, { "function_name": "Exp_Main.test", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "self._get_data", "functionality": "Gets the dataset and data loader for the test set.", "input": "flag='test'", "output": "A tuple of dataset and data loader.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "self.model.load_state_dict", "functionality": "Loads a model's parameter dictionary from a checkpoint file.", "input": "torch.load(os.path.join('./checkpoints/' + setting, 'checkpoint.pth'))", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "torch.load", "functionality": "Loads an object saved with torch.save() from a file.", "input": "os.path.join('./checkpoints/' + setting, 'checkpoint.pth')", "output": "The loaded state dictionary.", "location_or_namespace": "torch" }, { "function_call_name": "os.path.join", "functionality": "Joins one or more path components intelligently.", "input": "'./test_results/' + setting + '/', str(i) + '.pdf'", "output": "A string representing the full path.", "location_or_namespace": "os.path" }, { "function_call_name": "os.makedirs", "functionality": "Recursive directory creation function.", "input": "folder_path", "output": "None", "location_or_namespace": "os" }, { "function_call_name": "self.model.eval", "functionality": "Sets the model to evaluation mode.", "input": "None", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "enumerate", "functionality": "Returns an enumerate object, which yields pairs containing a count and a value from the iterable.", "input": "test_loader", "output": "An iterator of (index, batch) tuples.", "location_or_namespace": "built-in" }, { "function_call_name": "torch.cat", "functionality": "Concatenates the given sequence of tensors in the given dimension.", "input": "[batch_y[:, :self.args.label_len, :], dec_inp], dim=1", "output": "A concatenated tensor.", "location_or_namespace": "torch" }, { "function_call_name": "self.model", "functionality": "Performs a forward pass of the model to generate predictions.", "input": "batch_x, batch_x_mark, dec_inp, batch_y_mark", "output": "The model's output tensor.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "detach", "functionality": "Returns a new tensor, detached from the current graph.", "input": "None", "output": "A detached tensor.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "visual", "functionality": "Generates and saves a plot visualizing the ground truth and prediction.", "input": "gt, pd, os.path.join(folder_path, str(i) + '.pdf')", "output": "None", "location_or_namespace": "utils/tools.py" }, { "function_call_name": "test_params_flop", "functionality": "Tests the model's parameters and FLOPs.", "input": "(batch_x.shape[1],batch_x.shape[2])", "output": "None", "location_or_namespace": "utils/tools.py" }, { "function_call_name": "np.concatenate", "functionality": "Joins a sequence of arrays along an existing axis.", "input": "preds, axis=0", "output": "The concatenated numpy array.", "location_or_namespace": "numpy" }, { "function_call_name": "metric", "functionality": "Computes various evaluation metrics like MSE, MAE, RSE, and CORR.", "input": "preds, trues", "output": "A tuple of metric values.", "location_or_namespace": "utils/metrics.py" }, { "function_call_name": "open", "functionality": "Opens a file and returns a corresponding file object.", "input": "'result.txt', 'a'", "output": "A file object.", "location_or_namespace": "built-in" }, { "function_call_name": "np.save", "functionality": "Saves an array to a binary file in NumPy .npy format.", "input": "folder_path + 'pred.npy', preds", "output": "None", "location_or_namespace": "numpy" } ] }, { "function_name": "Exp_Main.predict", "file_path": "exp/exp_main.py", "function_calls": [ { "function_call_name": "self._get_data", "functionality": "Gets the dataset and data loader for prediction.", "input": "flag='pred'", "output": "A tuple of dataset and data loader.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "os.path.join", "functionality": "Joins one or more path components intelligently.", "input": "self.args.checkpoints, setting", "output": "A string representing the full path.", "location_or_namespace": "os.path" }, { "function_call_name": "self.model.load_state_dict", "functionality": "Loads a model's parameter dictionary from a checkpoint file.", "input": "torch.load(best_model_path)", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "torch.load", "functionality": "Loads an object saved with torch.save() from a file.", "input": "best_model_path", "output": "The loaded state dictionary.", "location_or_namespace": "torch" }, { "function_call_name": "self.model.eval", "functionality": "Sets the model to evaluation mode.", "input": "None", "output": "None", "location_or_namespace": "torch.nn.Module" }, { "function_call_name": "enumerate", "functionality": "Returns an enumerate object, which yields pairs containing a count and a value from the iterable.", "input": "pred_loader", "output": "An iterator of (index, batch) tuples.", "location_or_namespace": "built-in" }, { "function_call_name": "torch.zeros", "functionality": "Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument.", "input": "[batch_y.shape[0], self.args.pred_len, batch_y.shape[2]]", "output": "A tensor of zeros.", "location_or_namespace": "torch" }, { "function_call_name": "torch.cat", "functionality": "Concatenates the given sequence of tensors in the given dimension.", "input": "[batch_y[:, :self.args.label_len, :], dec_inp], dim=1", "output": "A concatenated tensor.", "location_or_namespace": "torch" }, { "function_call_name": "self.model", "functionality": "Performs a forward pass of the model to generate predictions.", "input": "batch_x, batch_x_mark, dec_inp, batch_y_mark", "output": "The model's output tensor.", "location_or_namespace": "exp/exp_main.py" }, { "function_call_name": "detach", "functionality": "Returns a new tensor, detached from the current graph.", "input": "None", "output": "A detached tensor.", "location_or_namespace": "torch.Tensor" }, { "function_call_name": "np.array", "functionality": "Creates a numpy array.", "input": "preds", "output": "A numpy array.", "location_or_namespace": "numpy" }, { "function_call_name": "np.concatenate", "functionality": "Joins a sequence of arrays along an existing axis.", "input": "preds, axis=0", "output": "The concatenated numpy array.", "location_or_namespace": "numpy" }, { "function_call_name": "pred_data.inverse_transform", "functionality": "Reverses the scaling transformation applied to the data.", "input": "preds", "output": "The inverse-transformed data.", "location_or_namespace": "data_provider/data_loader.py" }, { "function_call_name": "os.makedirs", "functionality": "Recursive directory creation function.", "input": "folder_path", "output": "None", "location_or_namespace": "os" }, { "function_call_name": "np.save", "functionality": "Saves an array to a binary file in NumPy .npy format.", "input": "folder_path + 'real_prediction.npy', preds", "output": "None", "location_or_namespace": "numpy" }, { "function_call_name": "pd.DataFrame", "functionality": "Creates a two-dimensional, size-mutable, potentially heterogeneous tabular data structure with labeled axes.", "input": "np.append(...), columns=pred_data.cols", "output": "A pandas DataFrame.", "location_or_namespace": "pandas" } ] } ]