值错误: 找不到可以处理输入的数据适配器:<类"exponents_processing_batches.序列_火车">,<类"无类型">



我的sequence_train类定义为:

class Sequence_train(Sequence):
def __init__(self, x_data, y_data, batch_size=10, n_variables=8):
self.x_data = x_data
self.y_data = y_data
self.batch_size = batch_size
self.n_variables = n_variables
def __len__(self):
return int(np.ceil(len(self.x_data)/float(self.batch_size)))
def __getitem__(self, item):
batch_x = self.x_data.iloc[item*self.batch_size:(item+1)*self.batch_size,:]
batch_y = self.y_data[item * self.batch_size:(item + 1) * self.batch_size]
k = []
for idx in batch_x.index:
k.append(list(filter(lambda v: v == v, batch_x.loc[idx])))
j = tensorflow.keras.preprocessing.sequence.pad_sequences(k, padding='post', value=0)
j = j.reshape([self.batch_size, int(j.shape[-1]/self.n_variables), self.n_variables])
return np.asarray(j),np.asarray(batch_y)

当我尝试在model.fit_generator(generator=x_train, epochs=50, verbose=2)中拟合x_train时我也试过没有发电机。ValueError:未能找到可以处理输入的数据适配器:<类'exponents_processing_batch>, <类'NoneType'>

之所以会出现错误,是因为您没有保证x_train、y_train、y_test和y_test数据是np.array()。看看这些变量,看看它们是在预期的dtype上还是在数组中。

train_x = np.asarray(train_x).astype('int32')

相关内容

  • 没有找到相关文章

最新更新