IndexError:维度1的张量的索引过多

时间:2018-07-19 11:47:04

标签: python-3.x deep-learning dataset lstm rnn

我目前正在研究RNN以进行异常检测。我正在使用自己的网络数据集。但是在运行下面的代码部分时

parser.add_argument('--data', type=str, default='EEGFAM',
                    help='type of the dataset (ecg, EEGFAM, gesture, power_demand, space_shuttle, respiration, nyc_taxi')
parser.add_argument('--filename', type=str, default='eeg.pkl',
                    help='filename of the dataset')
parser.add_argument('--model', type=str, default='LSTM',
                    help='type of recurrent net (RNN_TANH, RNN_RELU, LSTM, GRU, SRU)')
parser.add_argument('--augment', type=bool, default=True,
                    help='augment')

TimeseriesData = preprocess_data.PickleDataLoad(data_type=args.data, filename=args.filename,
                                                augment_test_data=args.augment)

上述子功能代码

with open(str(path), 'rb') as f:
            data = torch.FloatTensor(pickle.load(f))
            #print(data)
            label = data[:,-1]
            print(label)
            data = data[:,:-1]
            print(data)

我遇到以下错误

> Traceback (most recent call last):   File "1_train_predictor.py", line
> 76, in <module>
>     augment_test_data=args.augment)   File "/home/mtp-1/pro/codes/RNN-Time-series-Anomaly-Detection-master/preprocess_data.py",
> line 23, in __init__
>     self.trainData, self.trainLabel = self.preprocessing(Path('dataset',data_type,'labeled','train',filename),train=True)
> File
> "/home/mtp-1/pro/codes/RNN-Time-series-Anomaly-Detection-master/preprocess_data.py",
> line 49, in preprocessing
>     label = data[:,-1] IndexError: too many indices for tensor of dimension 1

我正在处理EEG数据,并且加载的文件由五个人的数据组成,其姓名为标签

请帮助我解决这个问题

0 个答案:

没有答案