Indexerror: อยู่นอกขอบเขตสำหรับข้อผิดพลาดขนาดใน keras convnet1D

ฉันกำลังพยายามใช้ CNN 1D สำหรับการทำนายอนุกรมเวลา ฉันมีชุดข้อมูลอนุกรมเวลาที่มีฟีเจอร์ 30 รายการ 3 เป้าหมาย และมากกว่า 3,000 แถว

นี่คือโมเดล keras ของฉัน

model = Sequential()
model.add(Embedding(64, 10, batch_input_shape=  (100,30))) #100 time steps and 30 features
model.add(Convolution1D(nb_filter=256,
                    filter_length=3,
                    border_mode='valid',
                    activation='relu',
                    subsample_length=1))

model.add(MaxPooling1D())
model.add(Convolution1D(nb_filter=150,
                    filter_length=3,
                    border_mode='valid',
                    activation='relu',
                    subsample_length=1))
model.add(MaxPooling1D())
model.add(Flatten())
model.add(Dropout(0.2))
model.add(Dense(3))
model.add(Activation('tanh'))
optimizer = RMSprop(lr=0.01)
model.compile(loss='mse', optimizer=optimizer)

model.fit(x,y)

โมเดลคอมไพล์โดยไม่มีข้อผิดพลาด แต่เมื่อฉันพยายามทำโมเดลให้พอดี มันก็ทำให้เกิดข้อผิดพลาดนี้

IndexError: index 124 is out of bounds for size 64
Apply node that caused the error: AdvancedSubtensor1(embedding_17_W, Reshape{1}.0)

ฉันเห็น คำตอบ นี้ แต่ x (ฟีเจอร์) และ y (เป้าหมาย) ของฉันอยู่ในรูปแบบอาร์เรย์ numpy แล้ว วิธีแก้ปัญหานี้?

แก้ไขแล้ว

หลังจากซ่อมแซม ฉันพบว่าปัญหาเกิดจากโมเดล CNN ของฉันเอง ฉันพยายามฝึกชุดข้อมูลเดียวกันด้วยโครงข่ายประสาทเทียมแบบธรรมดา และมันก็ทำงานได้โดยไม่มีปัญหาใดๆ

model = Sequential()
model.add(Dense(30, input_dim=30))
model.add(Activation('tanh'))
model.add(Dense(15))
model.add(Activation('tanh'))
model.add(Dropout(0.2))
model.add(Dense(3))
model.add(Activation('tanh'))
optimizer = RMSprop(lr=0.01)
model.compile(loss='mse', optimizer=optimizer)

model.fit(x,y)

มีใครรู้บ้างว่ามีอะไรผิดปกติกับโมเดล CNN ของฉัน


person Eka    schedule 18.01.2017    source แหล่งที่มา
comment
ปัญหาในเลเยอร์การฝังของคุณ: แทนที่จะเป็น 64 ควรเป็น 1 + max_index   -  person Alexey Golyshev    schedule 18.01.2017
comment
มันแสดงข้อผิดพลาดเดียวกัน IndexError: index 3 is out of bounds for size 1   -  person Eka    schedule 18.01.2017
comment
คุณไม่เข้าใจฉัน. ดูเอกสารประกอบของ Keras: input_dim: int > 0. Size of the vocabulary, ie. 1 + maximum integer index occurring in the input data การฝังของคุณควรเป็น 125 หรือมากกว่า ประเมิน numpy.max(x) และบวก 1 (ดัชนี 0 ถูกสงวนไว้สำหรับค่าที่ไม่รู้จัก)   -  person Alexey Golyshev    schedule 18.01.2017