Я пытаюсь выполнить этот код, я выполняю NLP в python
def load_data_from_fixed_indices(self, indices_file, datasets = ['train', 'valid', 'test']):
print(' ---> loading data from fixed indices:',indices_file)
corpusreader = PickledCorpusReader('preprocessed/corpus_normalized')
labelreader = PickledCorpusReader('preprocessed/labellisation/Autonomous Car')
loader = CorpusLoader(corpusreader, labelreader, level='sentence')
x_test, y_test, i_test = loader.load(idx_file=indices_file,
datasets_from_file= ['test'],
include_tfidf = False)
x_train, y_train, i_train = loader.load(idx_file=indices_file,
datasets_from_file= ['train'],
include_tfidf = False)
Но у меня такая ошибка:
Traceback (most recent call last):
File "parallel.py", line 455, in <module>
_, delta = p.load_data_from_fixed_indices('indices1575646151.0974712.pkl')
File "parallel.py", line 56, in wrapper
result = func(*args, **kwargs)
File "parallel.py", line 341, in load_data_from_fixed_indices
include_tfidf = False)
File "C:\Users\iduboc\Documents\asd-dev\toolbox\loader.py", line 246, in load
idx = sorted(idx)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
функция загружается в загрузчик. py вызывает ошибку и спрашивает в комментарии
def load(self,
idx=None,
idx_file='',
datasets_from_file=None,
numerical = False,
include_tfidf = True,
labelFilter=None,
ignoreEmpty=True,
return_generator = False,
return_ndarray=True):
if numerical and not (labelFilter is None) and isinstance(labelFilter[0], str):
labelFilter = [self.label2number[label] for label in labelFilter]
if not datasets_from_file is None:
if not (idx is None):
raise ValueError('Please specify either indices to use or
file, not both.')
# Load and Select file data
with open(idx_file, 'rb') as f:
self.indices = cloudpickle.load(f)
idx = []
for dataset in datasets_from_file:
idx += list(self.indices[dataset])
if not idx is None:
idx = sorted(idx)