title: Keras, get output of a layer at each epochs
body: <p><strong>What I have done?</strong></p>
  
  <p>I implemented a <code>keras</code> model as follow:</p>
  
  <pre><code>train_X, test_X, train_Y, test_Y = train_test_split(X, Y, test_size=0.2, random_state=np.random.seed(7), shuffle=True)
  
  train_X = np.reshape(train_X, (train_X.shape[0], 1, train_X.shape[1]))
  test_X = np.reshape(test_X, (test_X.shape[0], 1, test_X.shape[1]))
  
  model = Sequential()
  model.add(LSTM(100, return_sequences=False, input_shape=(train_X.shape[1], train_X.shape[2])))
  model.add(Dense(train_Y.shape[1], activation='softmax'))
  model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
  
  model.fit(train_X, train_Y, validation_split=.20,
                          epochs=1000, batch_size=50)
  </code></pre>
  
  <p><strong>What i want?</strong></p>
  
  <p>I want to give <code>support vector machine(SVM)</code> the output of the penultimate layer (LSTM), in any <code>epoch</code>(that is 1000) to <code>svm</code> also be trained.</p>
  
  <p>But I do not know how to do this?</p>
  
  <p>Any idea?</p>
  
  <p><strong>UPDATED:</strong></p>
  
  <p>I use from <code>ModelCheckpoint</code> as follow:</p>
  
  <pre><code>model = Sequential()
  model.add(LSTM(100, return_sequences=False, input_shape=(train_X.shape[1], train_X.shape[2])))
  model.add(Dense(train_Y.shape[1], activation='softmax'))
  model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
  
  # checkpoint
  filepath="weights-{epoch:02d}-{val_acc:.2f}.hdf5"
  checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
  callbacks_list = [checkpoint]
  
  model.fit(train_X, train_Y, validation_split=.20,
                      epochs=1000, batch_size=50, callbacks=callbacks_list, verbose=0)
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>Epoch 00991: val_acc did not improve
  Epoch 00992: val_acc improved from 0.93465 to 0.93900, saving model to weights-992-0.94.hdf5
  Epoch 00993: val_acc did not improve
  Epoch 00994: val_acc did not improve
  Epoch 00995: val_acc did not improve
  Epoch 00996: val_acc did not improve
  Epoch 00997: val_acc did not improve
  Epoch 00998: val_acc improved from 0.93900 to 0.94543, saving model to weights-998-0.94.hdf5
  Epoch 00999: val_acc did not improve
  </code></pre>
  
  <p><strong>PROBLEM:</strong></p>
  
  <p>How to load all these models to obtain the output of the LSTM layer in each epochs as @IonicSolutions said?</p>