我想建立一个LSTM网络,我有很长的信号要用作训练数据
def generate_data_to_model(y_train):
while True:
with open("/mypath/myData.csv") as f:
for line in f:
x= line.rstrip('\n').split(",")
x= np.asarray(x)
x=x[1:]
x= x.reshape(1,1,12)
yield (x, y_train[line])
model = Sequential()
model.add(LSTM(32, input_shape=(1, 12)))
model.add(Dense(32, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(9, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer="Adam", metrics=['acc'])
model.fit_generator(generate_data_to_model(y_train),
steps_per_epoch=1, epochs=2, verbose=1)
当我开始训练时,出现此错误:
<ipython-input-29-33b2195fea44> in generate_data_to_model(y_train) 8 x= x.reshape(1,1,12) ---> 9 yield (x, y_train[line])
仅整数,切片(:
),省略号(...
),numpy.newaxis(None
)和整数或布尔数组为有效索引我想建立一个LSTM网络,我有一个很长的信号要用作训练数据。我的X_train是一个CSV文件,其中包含12个信号,长度为54837488我的y_train是一个...