Open moghadas76 opened 9 months ago
Hello, Im Also getting the same error, can someone please check
**>
dataset
= get_dataset("solar_nips", regenerate=False) dataset.metadata train_grouper = MultivariateGrouper(max_target_dim=int(dataset.metadata.feat_static_cat[0].cardinality))test_grouper = MultivariateGrouper(num_test_dates=int(len(dataset.test)/len(dataset.train)), max_target_dim=int(dataset.metadata.feat_static_cat[0].cardinality)) dataset_train = train_grouper(dataset.train) dataset_test =
test_grouper(dataset.test)
**
ValueError Traceback (most recent call last) Cell In[7], line 2 1 dataset_train = train_grouper(dataset.train) ----> 2 dataset_test = test_grouper(dataset.test)
File ~\anaconda3\envs\Thesis_2\lib\site-packages\gluonts\dataset\multivariate_grouper.py:87, in MultivariateGrouper.call(self, dataset) 85 def call(self, dataset: Dataset) -> Dataset: 86 self._preprocess(dataset) ---> 87 return self._group_all(dataset)
File ~\anaconda3\envs\Thesis_2\lib\site-packages\gluonts\dataset\multivariate_grouper.py:125, in MultivariateGrouper._group_all(self, dataset) 123 grouped_dataset = self._prepare_train_data(dataset) 124 else: --> 125 grouped_dataset = self._prepare_test_data(dataset) 126 return grouped_dataset
File ~\anaconda3\envs\Thesis_2\lib\site-packages\gluonts\dataset\multivariate_grouper.py:152, in MultivariateGrouper._prepare_test_data(self, dataset) 148 assert self.num_test_dates is not None 150 logging.info("group test time series to datasets") --> 152 grouped_data = self._transform_target(self._left_pad_data, dataset) 153 # splits test dataset with rolling date into N R^d time series where 154 # N is the number of rolling evaluation dates 155 split_dataset = np.split( 156 grouped_data[FieldName.TARGET], self.num_test_dates 157 )
File ~\anaconda3\envs\Thesis_2\lib\site-packages\gluonts\dataset\multivariate_grouper.py:205, in MultivariateGrouper._transform_target(funcs, dataset) 203 @staticmethod 204 def _transform_target(funcs, dataset: Dataset) -> DataEntry: --> 205 return {FieldName.TARGET: np.array([funcs(data) for data in dataset])}
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (959,) + inhomogeneous part.
Hello, I have the error as well. `# Load the tokenized datasets train_dataset = load_from_disk('train_dataset') eval_dataset = load_from_disk('eval_dataset')
df = pd.read_csv('Data/clang8.csv')
dataset = Dataset.from_pandas(df)
train_test_split = dataset.train_test_split(test_size=0.1)
model = T5ForConditionalGeneration.from_pretrained('./results/checkpoint-3000')
tokenizer = AutoTokenizer.from_pretrained('t5-small')
training_args = TrainingArguments( output_dir='./results', per_device_eval_batch_size=2, # Reduced batch size for evaluation )
trainer = Trainer( model=model, args=training_args, eval_dataset=eval_dataset, tokenizer=tokenizer, )
predictions = trainer.predict(eval_dataset)
print("Checking predictions: "+str(len(predictions))) print(predictions)
predictions = np.asarray(predictions, dtype='object')
pred_texts = tokenizer.batch_decode(np.squeeze(predictions), skip_special_tokens=True)
with open('predictions.txt', 'w') as pred_file, open('references.txt', 'w') as ref_file: for pred, ref in zip(pred_texts, eval_dataset['Column2']): pred_file.write(pred + '\n') ref_file.write(ref.strip() + '\n')
annotator = errant.load('en')
with open('predictions.txt', 'r') as pred_file, open('references.txt', 'r') as ref_file: pred_sents = pred_file.readlines() ref_sents = ref_file.readlines()
aligned = [] for pred, ref in zip(pred_sents, ref_sents): pred_sent = annotator.parse(pred.strip()) ref_sent = annotator.parse(ref.strip()) aligned.append(annotator.align(pred_sent, ref_sent))
P, R, F = errant.scorer(aligned) print(f'Precision: {P:.2f}, Recall: {R:.2f}, F0.5: {F:.2f}')`
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (32,) + inhomogeneous part.
`from typing import Any, Dict, Iterable, Optional from gluonts.dataset.loader import TrainDataLoader from gluonts.itertools import Cached from gluonts.torch.batchify import batchify import pytorch_lightning as pl import torch from gluonts.core.component import validated from gluonts.dataset.common import Dataset from gluonts.dataset.field_names import FieldName from gluonts.dataset.loader import as_stacked_batches from gluonts.dataset.stat import calculate_dataset_statistics from gluonts.itertools import Cyclic from gluonts.time_feature import ( get_lags_for_frequency, time_features_from_frequency_str, ) from gluonts.torch.model.estimator import PyTorchLightningEstimator from gluonts.torch.model.predictor import PyTorchPredictor from gluonts.torch.modules.loss import DistributionLoss, NegativeLogLikelihood from gluonts.transform import ( AddObservedValuesIndicator, AddTimeFeatures, Chain, DummyValueImputation, ExpectedNumInstanceSampler, InstanceSampler, InstanceSplitter, TestSplitSampler, Transformation, ValidationSplitSampler, VstackFeatures ) from peft import LoraConfig, get_peft_model
from gluonts.torch.model.deepar import DeepAREstimator from gluonts.torch.distributions import StudentTOutput, NormalOutput from gluon_utils.gluon_ts_distributions.implicit_quantile_network import ( ImplicitQuantileNetworkOutput, )
from lag_llama.gluon.lightning_module import LagLlamaLightningModule
PREDICTION_INPUT_NAMES = [ "past_target", "past_observed_values", ] TRAINING_INPUT_NAMES = PREDICTION_INPUT_NAMES + [ "future_target", "future_observed_values", ]
class LagLlamaEstimator(PyTorchLightningEstimator): """ An estimator training a ConvTSMixer model for forecasting.
`